Sha256: 96b4cdfe142b52d0deb5105b91153349c66a1209fb3b4e2236b84486fc99b453
Contents?: true
Size: 1.98 KB
Versions: 1
Compression:
Stored size: 1.98 KB
Contents
/**========================================================= * Module: play-animation.js * Provides a simple way to run animation with a trigger * Targeted elements must have * [data-animate"] * [data-target="Target element affected by the animation"] * [data-play="Animation name (http://daneden.github.io/animate.css/)"] * * Requires animo.js =========================================================*/ (function($, window, document){ 'use strict'; var Selector = '[data-animate]'; $(function() { var $scroller = $(window).add('body, .wrapper'); // Parse animations params and attach trigger to scroll $(Selector).each(function() { var $this = $(this), offset = $this.data('offset'), delay = $this.data('delay') || 100, // milliseconds animation = $this.data('play') || 'bounce'; if(typeof offset !== 'undefined') { // test if the element starts visible testAnimation($this); // test on scroll $scroller.scroll(function(){ testAnimation($this); }); } // Test an element visibilty and trigger the given animation function testAnimation(element) { if ( !element.hasClass('anim-running') && $.Utils.isInView(element, {topoffset: offset})) { element .addClass('anim-running'); setTimeout(function() { element .addClass('anim-done') .animo( { animation: animation, duration: 0.7} ); }, delay); } } }); // Run click triggered animations $(document).on('click', Selector, function() { var $this = $(this), targetSel = $this.data('target'), animation = $this.data('play') || 'bounce', target = $(targetSel); if(target && target.length) { target.animo( { animation: animation } ); } }); }); }(jQuery, window, document));
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
radius-rails-3.1.4 | app/assets/javascripts/radius-theme/modules/play-animation.js |