self-scroll
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -10,4 +10,4 @@ class Scroll { | ||
constructor(targetP, target, scrollOption = {}) { | ||
// console.log(targetP); | ||
// console.log(target); | ||
// // console.log(targetP); | ||
// // console.log(target); | ||
@@ -20,3 +20,3 @@ this._targetP = targetP; | ||
// console.log(this); | ||
// // console.log(this); | ||
@@ -69,2 +69,4 @@ this.pNodeW = targetP.getBoundingClientRect().width; | ||
this.stopScroll = this.stopScroll.bind(this); | ||
this.stopGlobalScrollFn = this.stopGlobalScrollFn.bind(this); | ||
this.resumeGlobalScrollFn = this.resumeGlobalScrollFn.bind(this); | ||
} | ||
@@ -98,3 +100,3 @@ /*** | ||
createScroll(){ | ||
// // // console.log('created!') | ||
// // // // console.log('created!') | ||
let _this = this; | ||
@@ -175,4 +177,4 @@ // 创建虚拟节点对象(文档碎片节点) | ||
// // // // console.log("172 ---》 ", _this.nowDomTrans) | ||
// // // // console.log("173 ---》 ", _this.nowScrollPos) | ||
// console.log("172 ---》 ", _this.nowDomTrans) | ||
// console.log("173 ---》 ", _this.nowScrollPos) | ||
} | ||
@@ -251,3 +253,3 @@ } | ||
if(!canCreateScroll && isRightDomList.length != 0){ | ||
// // // // console.log('348 ---> ','置顶!') | ||
// // // // // console.log('348 ---> ','置顶!') | ||
_this.nowDomTrans = 0; | ||
@@ -290,2 +292,5 @@ _this.nowScrollPos = 0; | ||
_this._targetP.onmouseenter = function(){ | ||
// 阻止浏览器滚动条滚动行为 | ||
_this.stopGlobalScrollFn(); | ||
_this.pNodeStyle['opacity'] = 1; | ||
@@ -305,8 +310,11 @@ _this.newScrollDomEle.style['opacity'] = 1; | ||
_this.newScrollDomEle.style['opacity'] = 0; | ||
// 恢复浏览器滚动条滚动行为 | ||
_this.resumeGlobalScrollFn(); | ||
} | ||
_this.stopScroll(); | ||
// _this.stopScroll(); | ||
} | ||
// // console.log('409',"12345678910") | ||
// // // console.log('409',"12345678910") | ||
_this[oldSizeKey] = realOffsetHeight; | ||
@@ -318,2 +326,13 @@ return; | ||
} | ||
stopWheel(e){ | ||
e.preventDefault(); | ||
} | ||
stopGlobalScrollFn(){ | ||
let _this = this; | ||
window.addEventListener('wheel',_this.stopWheel,{passive:false}); | ||
} | ||
resumeGlobalScrollFn(){ | ||
let _this = this; | ||
window.removeEventListener('wheel',_this.stopWheel); | ||
} | ||
stopScroll(){ | ||
@@ -448,4 +467,4 @@ // 禁止最外层滚动条滚动 | ||
// // console.log(event.target); | ||
// console.log(resTargetP); | ||
// // // console.log(event.target); | ||
// // console.log(resTargetP); | ||
@@ -534,3 +553,3 @@ | ||
// moveUp moveDown | ||
// console.log('512 ---> ',this); | ||
// // console.log('512 ---> ',this); | ||
this['move' + dir](); | ||
@@ -643,4 +662,4 @@ } | ||
// // console.log('652 ---',this._target) | ||
// // console.log('653 ---',this._targetP) | ||
// // // console.log('652 ---',this._target) | ||
// // // console.log('653 ---',this._targetP) | ||
@@ -647,0 +666,0 @@ |
21
index.js
@@ -67,2 +67,4 @@ export class Scroll { | ||
this.stopScroll = this.stopScroll.bind(this); | ||
this.stopGlobalScrollFn = this.stopGlobalScrollFn.bind(this); | ||
this.resumeGlobalScrollFn = this.resumeGlobalScrollFn.bind(this); | ||
} | ||
@@ -285,2 +287,5 @@ /*** | ||
_this._targetP.onmouseenter = function(){ | ||
// 阻止浏览器滚动条滚动行为 | ||
_this.stopGlobalScrollFn(); | ||
_this.pNodeStyle['opacity'] = 1; | ||
@@ -300,5 +305,8 @@ _this.newScrollDomEle.style['opacity'] = 1; | ||
_this.newScrollDomEle.style['opacity'] = 0; | ||
// 恢复浏览器滚动条滚动行为 | ||
_this.resumeGlobalScrollFn(); | ||
} | ||
_this.stopScroll(); | ||
// _this.stopScroll(); | ||
} | ||
@@ -313,2 +321,13 @@ | ||
} | ||
stopWheel(e){ | ||
e.preventDefault(); | ||
} | ||
stopGlobalScrollFn(){ | ||
let _this = this; | ||
window.addEventListener('wheel',_this.stopWheel,{passive:false}); | ||
} | ||
resumeGlobalScrollFn(){ | ||
let _this = this; | ||
window.removeEventListener('wheel',_this.stopWheel); | ||
} | ||
stopScroll(){ | ||
@@ -315,0 +334,0 @@ // 禁止最外层滚动条滚动 |
{ | ||
"name": "self-scroll", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "You can customize the scroll bar(Compatible with Firefox,IE,Ghrome)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71551
1080