Written by Jonathan James Cosgrove
A jQuery plugin that works in harmony with animate.css in order to enable animations only when content comes into view.
**update** Now supports v4 of animate.css
jQuery AniView is a minimal (~1KB) jQuery plugin that allows you to add animations to your
webpages with nothing more than a class identifier and a single data attribute. There are also a
couple of optional... options.
Scroll down to see how it works!
$('.aniview').AniView();
var options = { animateClass: 'animated', // for v3 or 'animate__animated' for v4 animateThreshold: 100, scrollPollInterval: 20 } $('.aniview').AniView(options);
<div class="aniview" data-av-animation="slideInRight"></div>
<div class="aniview" data-av-animation="animate__jackInTheBox"></div>
As you scroll down the page, each animation is triggered when the threshold is met. i.e. when it comes into view by way of the bottom of the user's screen (viewport).
Since it uses the freakin awesome animate.css - it supports all of the same animations that it does.
All you have to do is simply declare what you want to use via the data-av-animation attribute.
You could even set up some custom animation classes so that animations occur in a specific order, e.g:
.fast { -vendor-animation-duration: 1s; -vendor-animation-delay: 0s; } .slow { -vendor-animation-duration: 3s; -vendor-animation-delay: 1s; } .reallyslow { -vendor-animation-duration: 6s; -vendor-animation-delay: 3s; }