mirror of
https://github.com/hanzo-apps/hanzo.io.git
synced 2026-10-30 19:15:19 +00:00
27 lines
661 B
JavaScript
27 lines
661 B
JavaScript
$(function() {
|
|
$('.animated').each(function() {
|
|
var $animated = $(this);
|
|
var scheduled = false;
|
|
var animation = $animated.css('animation-name');
|
|
$animated.removeClass(animation);
|
|
|
|
var animateFn = function(){
|
|
if (!scheduled) {
|
|
requestAnimationFrame(function(){
|
|
var offset = $animated.offset();
|
|
if (offset.top < ($(window).height() + $(window).scrollTop())) {
|
|
$animated.addClass(animation);
|
|
} else {
|
|
scheduled = false;
|
|
}
|
|
});
|
|
scheduled = true;
|
|
}
|
|
};
|
|
|
|
$(window).on('scroll touchmove mousewheel', animateFn);
|
|
|
|
animateFn();
|
|
});
|
|
});
|