动画不会显示隐藏的块

奇科3001

我尝试制作自己的wow.js版本有两个原因,第一个原因是wow.js似乎不再得到维护,第二个原因是它只显示一次动画

我的问题是我的代码向下滚动时不显示动画,只有向上滚动时才显示动画,我能找到原因...

谁能帮我找到错误?

负责显示元素的功能是这样的:

function showBlocks() {
    $('.wow2').each(function () {
        var elementTop = $(this).data('wow2-top');

        $(this).html(elementTop);

        // Shows Elements
        if ((elementTop >= top) && (elementTop <= bottom)) {
            $(this).css('visibility', 'visible');
            $(this).addClass('animated').addClass($(this).data('wow2-class'));
        }
        /*
         // Hides Elements
         if ((elementTop < top) || (elementTop >= bottom)) {
         $(this).css('visibility', 'hidden');
         $(this).removeClass('animated').removeClass($(this).data('wow2-class'));
         }
         */
    });

}

这是我的jsfiddle

克莱顿·莱斯(Clayton Leis)

滚动时,您正在更新的值,top但没有更新bottom尝试

$(window).scroll(function () {
    top = $(window).scrollTop();
    bottom = top + viewportHeight;
    showBlocks();
    writePosition();
});

https://jsfiddle.net/5q7gryqr/4/

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章