Github
https://github.com/Q42/delighters
Demo
http://www.bestjquery.com/?zEyuV1UF
Add CSS animations to delight users as they scroll down. A tiny javascript library by Q42. It was written by Martin Kool.
See the demo here
<script type="text/javascript" src="delighters.js">
<div class="foo" data-delighter>
.started
and .ended
When the library loads, each [data-delighter] gets the .delighter class.
.foo.delighter { transition: all .3s ease-out; transform: translateX(-100%); opacity: 0; }
The .started
class is set when the top of [data-delighter] element is at 0.75 of the viewport (where 0 is top and 1 is bottom).
.foo.delighter.started { transform: none; opacity: 1; }
An extra .ended
class is set when the bottom of [data-delighter] element is at 0.75 of the viewport (where 0 is top and 1 is bottom).
.foo.delighter.started.ended { border: solid red 10px; }
.started
class when its top raises above 75% of the browser's viewport height.ended
is addeddata-delighter="start:0.5;end:0.95;
start:1.2;end:-0.3
data-delighter="debug"
flag to enable debugging for that delighter0.75
0.75
By default, delighters.js intializes automatically when the DOM is ready, and with the following configuration:
options = { attribute: 'data-delighter', classNames: ['delighter', 'started', 'ended'], start: 0.75, // default start threshold end: 0.75, // default end threshold autoInit: true // initialize when DOMContentLoaded }
You can customize any or all of the above properties using:
Delighters.config({ // set the default start threshold at the bottom start: 1, // let's call Delighters.init() manually later autoInit: false // ... etc ... })