Javascript 垂直时间线在chrome浏览器中不起作用

Javascript 垂直时间线在chrome浏览器中不起作用,javascript,css,ruby-on-rails,google-chrome,Javascript,Css,Ruby On Rails,Google Chrome,我为RubyonRails应用程序使用垂直时间线。除了chrome浏览器之外,它工作得很好。动画在谷歌浏览器中不起作用。我想这是剧本里写的!!!!。有人能提出解决办法吗。我的剧本是 <script> jQuery(document).ready(function($){ var timelineBlocks = $('.cd-timeline-block'), offset = 0.8; //hide timeline blocks which ar

我为RubyonRails应用程序使用垂直时间线。除了chrome浏览器之外,它工作得很好。动画在谷歌浏览器中不起作用。我想这是剧本里写的!!!!。有人能提出解决办法吗。我的剧本是

<script>
jQuery(document).ready(function($){
    var timelineBlocks = $('.cd-timeline-block'),
        offset = 0.8;

    //hide timeline blocks which are outside the viewport
    hideBlocks(timelineBlocks, offset);

    document.getElementById("body").onscroll = function() {myFunction()};

    //on scolling, show/animate timeline blocks when enter the viewport
    function myFunction() {
        (!window.requestAnimationFrame) 
            ? setTimeout(function(){ showBlocks(timelineBlocks, offset); }, 100)
            : window.requestAnimationFrame(function(){ showBlocks(timelineBlocks, offset); });
    }

    function hideBlocks(blocks, offset) {
        blocks.each(function(){
            ( $(this).offset().top > $(window).scrollTop()+$(window).height()*offset ) && $(this).find('.cd-timeline-img, .cd-timeline-content').addClass('is-hidden');
        });
    }

    function showBlocks(blocks, offset) {
        blocks.each(function(){
            ( $(this).offset().top <= $(window).scrollTop()+$(window).height()*offset && $(this).find('.cd-timeline-img').hasClass('is-hidden') ) && $(this).find('.cd-timeline-img, .cd-timeline-content').removeClass('is-hidden').addClass('bounce-in');
        });
    }
});

jQuery(文档).ready(函数($){
var timelineBlocks=$('.cd timeline block'),
偏移量=0.8;
//隐藏视口外部的时间线块
隐藏块(时间线块、偏移);
document.getElementById(“body”).onscroll=function(){myFunction()};
//在旋转时,在进入视口时显示/设置时间线块的动画
函数myFunction(){
(!window.requestAnimationFrame)
?设置超时(函数(){showBlocks(timelineBlocks,offset);},100)
:window.requestAnimationFrame(函数(){showBlocks(timelineBlocks,offset);});
}
功能隐藏块(块、偏移){
块。每个(函数(){
($(this).offset().top>$(window).scrollTop()+$(window).height()*offset)和&$(this).find('.cd timeline img,.cd timeline content').addClass('is-hidden');
});
}
功能显示块(块、偏移){
块。每个(函数(){

($(this).offset().topIts
document.getElementById(“body”).onscroll=function(){myFunction()};
在chrome上无法正常工作

将此脚本用于onScroll事件:

$(window).on('scroll', function(){
    (!window.requestAnimationFrame) 
        ? setTimeout(function(){ showBlocks(timelineBlocks, offset); }, 100)
        : window.requestAnimationFrame(function(){ showBlocks(timelineBlocks, offset); });
});
参考:

让我知道你的反馈!
谢谢

Ya…很好。很抱歉,我没有足够的声誉来支持这个问题。但这很有效。谢谢