账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    手动触发scroll之后设置scrollTop值无效
    • 2017-08-21 00:00
    • 10
    24
    0

    手动触发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);
    
    //执行完这一段代码之后,如果手动滚动屏幕了,有些低版本的手机需再次点击屏幕才会执行这个定时器
    0
    打赏
    收藏
    点击回答
    您的回答被采纳后将获得:提问者悬赏的 10 元积分
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部