为了账号安全,请及时绑定邮箱和手机立即绑定

为什么不能移动文档内容

if(sliderEl){

       var doc = this.$doc,//获取文本对象
       dragStartPagePosition,//鼠标起始位置
       dragStartScrollPosition,//元素内容的起始位置
       dragContBarRate;//???
       function mousemoveHandler() {
           e.preventDefault();
           console.log("mousemove");
           if(dragStartPagePosition == null){
               return ;
           }
           self.scrollTo(dragStartScrollPosition + (e.pageY-dragStartPagePosition)*0.5);
       }
       slider.on("mousedown",function (e) {
           e.preventDefault();//去除文本对象默认功能
           console.log("mousedown");
           dragStartPagePosition = e.pageY;//获取鼠标距离文档顶部的距离
           alert('1'+self.$cont[0].scrollTop);
           dragStartScrollPosition = self.$cont[0].scrollTop;//滚动区内容对象的起始数据
           alert('2');
           alert("dragStartPagePosition"+dragStartPagePosition+"dragStartScrollPosition"+dragStartScrollPosition)
           doc.on("mousemove.scroll", mousemoveHandler())
               .on("mouseup.scroll",function (e) {
                   console.log("mouseup");
                   doc.off(".scroll")
                   });
       });
   }
   return self;
},
//内容可滚动的高度
getMaxScrollPosition:function () {
    var self = this;
    //获取滚动条内容高度:可视区和元素内容高度的最大值
    return Math.max(self.$cont.height(),self.$cont[0].scrollHeight)-self.$cont.height();
    //内容可滚动的距离为:文本内容高度-可视区内容高度,当文本内容高度小于可视区时可移动距离为0
},
//滑块可移动的高度
getMaxSliderPosition:function () {
   var self = this;
   return self.$bar.height() - self.$slider.height();//可移动的高度就是滚动条的高度-滑块的高度
},
//滚动函数
scrollTo:function (positionVal) {
   var self = this;
   self.$cont.scrollTop(positionVal);//设置每个匹配元素的垂直滚动条位置,元素内容超出上边界的像素
}

正在回答

1 回答

举报

0/150
提交
取消

为什么不能移动文档内容

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信