Browse Source

自定义滚动条

zhangxc 5 năm trước cách đây
mục cha
commit
09bee41dd7
1 tập tin đã thay đổi với 7 bổ sung2 xóa
  1. 7 2
      src/js/scrollBar.js

+ 7 - 2
src/js/scrollBar.js

@@ -14,7 +14,6 @@
                     e.preventDefault();  
                 },false);   
             }else{  
-                console.log('AAAAAAAAAAAAA', _this.scrollTop += e.wheelDelta )
                 _this.onmousewheel = function(e){     
                     e = e || window.event;     
                     _this.scrollTop += e.wheelDelta > 0 ? -60 : 60;     
@@ -146,7 +145,7 @@
       var self = this;
       const paddingTop = parseInt(self.$cont.css("paddingTop"))
       const paddingBottom = parseInt(self.$cont.css("paddingBottom"))
-      return self.$bar.height()+paddingTop*2+paddingBottom*2 + - self.$slider.height();
+      return self.$bar.height()+paddingTop*3+paddingBottom*3 + - self.$slider.height();
     },
 
     // 监听内容的滚动,同步滑块的位置
@@ -168,6 +167,7 @@
       // on监听事件,多个事件利用空格分开
       self.$cont.on('mousewheel DOMMouseScroll',function(e){
         e.preventDefault();
+     
         // 判断原生事件对象的属性
         var oEv = e.originalEvent,
         //原生事件对象,(其他浏览器负数向下,firefox正数向下,所以在wheelDelta前面有负数)
@@ -175,6 +175,11 @@
             wheelRange = oEv.wheelDelta ? -oEv.wheelDelta/120 : (oEv.detail || 0)/3;
             // 调用scrollTo方法。
             self.scrollTo(self.$cont[0].scrollTop + wheelRange*self.options.wheelStep)
+            console.log()
+            if(self.$cont[0].scrollTop !==0 ){
+              e.stopPropagation()
+            }
+           
       });
     },