このチュートリアルを使用してスクロールでCSSアニメーションをアクティブ化しようとしましたhttp://codepen.io/benske/full/yJoqz。スクロールのJquery CSSアニメーションが期待通りに機能しない
私が改正されている唯一のものは、無競合モードで動作するようにjqueryのある、
私のバージョン:
<script>
jQuery(function() {
var $window = $(window),
win_height_padded = $window.height() * 1.1,
isTouch = Modernizr.touch;
if (isTouch) { $('.revealOnScroll').addClass('animated'); }
$window.on('scroll', revealOnScroll);
function revealOnScroll() {
var scrolled = $window.scrollTop(),
win_height_padded = $window.height() * 1.1;
// Showed...
jQuery(".revealOnScroll:not(.animated)").each(function() {
var $this = $(this),
offsetTop = $this.offset().top;
if (scrolled + win_height_padded > offsetTop) {
if ($this.data('timeout')) {
window.setTimeout(function(){
$this.addClass('animated ' + $this.data('animation'));
}, parseInt($this.data('timeout'),10));
} else {
$this.addClass('animated ' + $this.data('animation'));
}
}
});
// Hidden...
jQuery(".revealOnScroll.animated").each(function (index) {
var $this = $(this),
offsetTop = $this.offset().top;
if (scrolled + win_height_padded < offsetTop) {
$(this).removeClass('animated fadeInUp flipInX lightSpeedIn')
}
});
}
revealOnScroll();
});
</script>
アイブ氏はアニメーションしかし、スクロールにあなたがスクロールアップするたびに活性化し得ることができましたアニメーションを削除します。スクロールバックすると、アニメーションが最後の数ミリ秒にスキップされることも、まったく再生されないこともあります。
私の試みはdev.silverfx.co.ukですが、上下にスクロールして見ることができますが、滑らかさをチュートリアルと比較するとすぐにわかります。
おかげ@Mkb、私が見たhaventこれは前に、かっこいい見えます。私はこれがちょうどチケットをすると思います! –