手動觸發scroll之后設置scrollTop值無效,需要手動點擊一下才頁面才會滾動,有人遇到過嗎?怎么解決的,貼出代碼!//topArr 是一個數組,每個div的getBoundingClientRect().top;_this.videoPlayer.on('playing',function(){_this.videoPlayer.setVideoMute(true);$section.parent().scrollTop(0);$section.find('.caption-detail').removeClass('location');var $clickSecion = $section.eq(0);var curIndex = -1;timer = setInterval(function(){ var ct = _this.videoPlayer.getVideoCurrentTime(); timeArr.forEach(function(item,index){ if(ct>=item.startTime && ct< item.endTime){ if(curIndex != index){ $clickSecion = $section.eq(index); var st = $section.get(index).getBoundingClientRect(); $section.find('.caption-detail').removeClass('location'); $clickSecion.find('.caption-detail').addClass('location'); $section.parent().animate({scrollTop: topArr[index]-topArr[0]},100,function(){ $section.parent().bind('scroll'); }); curIndex = index; } } });},100);
手動觸發scroll之后設置scrollTop值無效
牧羊人nacy
2018-12-21 15:14:24