• Stars
    star
    295
  • Rank 135,696 (Top 3 %)
  • Language
    JavaScript
  • Created over 9 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Javascript for adding small easter eggs when over scrolling on apple devices.

Overscroll.js

A tiny javascript library, to capture the moments when you've scrolled more than the screen allows (osx/ios)... so we can sneak in some little easter eggs. Here's a live demo, and here's a video !

Instructions

Overscroll.js is a stand alone library (no jquery, or the likes) so usage is pretty straight forward. All styling of easter egg elements is up to the user, Overscroll.js only handles moving your elements onto/off the screen, when you are scrolling beyond the pages height.

HTML

There aren't any restrictions for the html overscroll can bind too, that said, you do need to position them (ideally off screen) yourself. Overscroll will handle their movement.

<!-- Any element works, really -->
<img class="easter-egg" src="./img/awesome-source.jpg" />

CSS

You'll need to position the element you want to slide in/out of the screen initially. Since overscroll edits the transform of your element, you should try to avoid using transforms on it too.

That said, your positioning doesn't need to be anything too complex. For example:

.easter-egg {
	/* Dimensions */
	width: 300px;
	height: 500px;
	
	/* Fixed position */
	position: fixed;
	left: 50%;
	top: 0px;

	/* Centered horizontally, and hidden above screen */
	margin-left: -150px;
	margin-top: -500px;
}

Above, the margin-top: -500px hides the element above the top of the screen, since overscroll will handle showing it when the there is overscroll in that direction.

JS

Overscroll.js is fairly straight forward when it comes to kicking it off, you'll need to create a new instance of overscroll (and include the script in the page), and then bind elements to it once they have been rendered. You can do this with document.querySelector.

<img class="easter-egg-element" src="./img/awesome-source.png" />

<script>
var overscroll = new Overscroll();
window.onload = function() {
	overscroll.bindElement(document.querySelector('.easter-egg-element'));
}
</script>

There are options, for when the easter egg is at the top, or bottom.

<img class="easter-egg-element top" src="./img/awesome-source.png" />
<img class="easter-egg-element bottom" src="./img/awesome-source.png" />

<script>
var overscroll = new Overscroll();
window.onload = function() {
	overscroll.bindElement(document.querySelector('.easter-egg-element.top'), 'top');
	overscroll.bindElement(document.querySelector('.easter-egg-element.bottom'), 'bottom');
}
</script>

And finally, a delta, to show how sensitive the scroll should be, when in the overscroll area... this makes it easier for people to find, but isn't really necessary.

<img class="easter-egg-element" src="./img/awesome-source.png" />

<script>
var overscroll = new Overscroll();
window.onload = function() {
	overscroll.bindElement(document.querySelector('.easter-egg-element'), 'top', 2);
}
</script>

Image/Example

Here's a couple of screenshots of Overscroll.js in action. You should really look at the demo though, to get a full feel for the interactions, or check out the video!

Overscroll on the bottom: Overscroll.js doing its thing

Overscroll on the top: Overscroll.js doing its thing

Browser support

Overscroll has been tested in the latest stable builds of Safari and Chrome. IE & Firefox don't really have the "overscroll" zones, so they won't work. Its just for fun... so not the end of the world ;)

License

The MIT License (MIT)

Copyright (C) 2017 ~ Tim Holman ~ [email protected]

More Repositories

1

elevator.js

Finally, a "back to top" button that behaves like a real elevator.
JavaScript
6,620
star
2

github-corners

A fresher "Fork me on GitHub" callout.
HTML
4,891
star
3

zenpen

A minimalist writing zone.
JavaScript
3,765
star
4

cursor-effects

Old-school cursor effects for your browser built with modern JavaScript
JavaScript
3,181
star
5

intense-images

A simple library to view large images up close using simple mouse interaction, and the full screen.
JavaScript
2,572
star
6

generative-artistry

A website for self coding generative art tutorials.
JavaScript
833
star
7

giflinks

The best thing to happen to the internet since the <a> tag.
JavaScript
796
star
8

dom-animator

A nifty javascript library to run animations, hidden in comment nodes, within the dom.
JavaScript
628
star
9

ascii-morph

Library to animate between two ascii images -
JavaScript
570
star
10

obnoxious.css

Animations for the strong of heart, and stupid of mind.
CSS
506
star
11

console-dot-frog

Forget console logs, console.frog is where its all at!
JavaScript
315
star
12

texter

Texter is a little app that lets you explore your creativity by drawing with text.
JavaScript
273
star
13

the-indie-web

A hotspot for indie creations on the web
CSS
250
star
14

tutorial-markdown

Interactive coding tutorials with markdown
JavaScript
241
star
15

what-have-you-made-today

Chrome & FireFox extension to replace the default home page. What have you made today?
Vue
231
star
16

discreet-twitter-ui

A minimal ui/ux concept for twitter buttons allowing hover reveals under an icon.
CSS
221
star
17

office-simulator

Miss the office life? You won't any more with this wonderful office slack simulator.
JavaScript
160
star
18

tileJs

Windows Metro Tiles with css3 and javascript
JavaScript
154
star
19

buddy

Chrome extension, and friend from hell
JavaScript
134
star
20

smelvetica

Sorry y'all, got a takedown from monotype.
134
star
21

bsod.js

Blue screen of death for the web, because debugging shouldn't be easy.
JavaScript
112
star
22

binary-music-player

A binary music player, with customizable notes & playback.
HTML
95
star
23

mosquito-js

An annoying mosquito created with the web audio api.
JavaScript
93
star
24

unicoder.js

A small js library to convert text into โ“ฃโ“”โ“งโ“ฃ.
JavaScript
92
star
25

console-fright-night

Open the browser console, get a fright. Just like that!
JavaScript
89
star
26

the-zen-zone

Digital meditation aid
JavaScript
80
star
27

the-pattern-library

A library of beautiful patterns, created by talented designers.
JavaScript
75
star
28

palettab

New fonts and colors with every new tab.
JavaScript
68
star
29

image-nodes

Javascript experiment using image data to create a small interactive particle system
CSS
58
star
30

emoji-intensifies

A quick and simple tool to make shaky "intensifies" emoji.
JavaScript
54
star
31

meettheipsums

A website to link out to all of the awesome filler text in the world.
HTML
52
star
32

s.js

Canvas JavaScript polyfill for the vital and pivotal S we all drew in school.
JavaScript
51
star
33

resizer

A small library to improve the user experience of a text box, by decreasing the font size slightly if it is filled with text.
JavaScript
49
star
34

the-internet

Basically the internet (or most important parts) in a module.
JavaScript
49
star
35

beautiful-curves

A simple generative drawing app using the html5 canvas
JavaScript
39
star
36

cant-not-tweet-this

Taking annoying social media popup crap to the next level!
CSS
37
star
37

concentrics

A little web experiment, using concentric circles and squares to create abstract arty stuff!
JavaScript
35
star
38

abstract-clocks

Abstract Clocks, telling the time in abstract & beautiful ways.
HTML
34
star
39

tetris-pieces

A beautiful AI Tetris, playing on your wall!
JavaScript
33
star
40

long-doge-challenge

The Long Doge Challenge
HTML
32
star
41

rasterizer

Experimenting with rasterization with javascript + the html5 canvas
JavaScript
30
star
42

checkboxrace

A checkbox based race
HTML
26
star
43

asciiFaceSaver

An osx screen saver, looping over various ascii faces. Written in Swift.
Swift
26
star
44

interactive-banners

A few html5 experiments using js/canvas to create interactive banners
JavaScript
25
star
45

useless-web-archive

An archive for the sites of "the useless web"
HTML
22
star
46

puginarug

Honor the Pug in a Rug
HTML
20
star
47

Dripping-Paint

Small html5 canvas experiment to simulate a simple dripping paint effect
JavaScript
19
star
48

mondrian-and-me

A "Useless Website" honoring Piet Mondrian's fantastic art.
HTML
19
star
49

tholman-blog

Source to my personal blog and website.
CSS
17
star
50

thats-the-finger

The finger. Thats it.
JavaScript
13
star
51

star-spangled-browser

A chrome plugin to blow minds when hovering the word america.
JavaScript
12
star
52

one-square-minesweeper

A game of minesweeper with only one square to sweep. Fun for the whole family.
CSS
10
star
53

scripts-for-life

A few bash shells scripts I use to make life easier.
Shell
8
star
54

human-music

Sit back and stretch your legs and enjoy the relaxing tunes of Earth radio.
HTML
5
star
55

tholman

A repo about me!
1
star