0
我一直试图在滚动上触发Animate.css动画。我使用以下jquery代码在我的页面上进行管理。它工作正常:在div高度触发CSS动画
$(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...
$(".revealOnScroll:not(.animated)").each(function() {
var $this = $(this),
offsetTop = $this.offset().top;
if (scrolled + win_height_padded > offsetTop+300) {
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...
$(".revealOnScroll.animated").each(function (index) {
var $this = $(this),
offsetTop = $this.offset().top;
if (scrolled + win_height_padded < offsetTop) {
$(this).removeClass('animated hinge fadeInLeft fadeIn pulse')
}
});
}
revealOnScroll();
});
但是,我有一个图像打开全屏div。我想在我的div内滚动时使用相同的效果。
我试图改变“窗口”与我的div的名称,但它不工作。
它确实存在。我确信这一点。但它仍然链接到第二页(div后面的那个) – Pierrealexisb
是为你的div设置高度和宽度,并溢出滚动? –
是的一切都按照你所说的设置。但我有一个隐藏溢出内的滚动(以防止主页溢出)。我不知道这是否是问题。 – Pierrealexisb