From ae1469333f1c421efeff0b14104cb00fc761e6fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Tue, 7 Jul 2020 10:56:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=BB=9A=E5=8A=A8=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=9C=A8=E5=BF=AB=E9=80=9F=E6=BB=9A=E5=8A=A8=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 5 +---- src/scroll/index.wc | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d720280..62ec262 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,7 @@ "type": "git", "url": "git+https://github.com/yutent/doui.git" }, - "keywords": [ - "doui", - "Anot" - ], + "keywords": ["doui", "Anot"], "author": "yutent", "license": "MIT", "dependencies": {}, diff --git a/src/scroll/index.wc b/src/scroll/index.wc index 24f0a1e..adab01e 100644 --- a/src/scroll/index.wc +++ b/src/scroll/index.wc @@ -255,11 +255,16 @@ export default class Scroll { if (!xw && !yh) { return } - // ev.preventDefault() //校正兼容苹果鼠标在 chrome和FF下滚动的精度 var deltaX var deltaY + var now = Date.now() + + if (!this.stamp || now - this.stamp > 1000) { + this.stamp = now + this.times = 1 + } if (IS_FF) { // 区分是触摸板还是普通鼠标 @@ -277,6 +282,16 @@ export default class Scroll { } } + if (now - this.stamp < 20) { + this.times += 0.05 + if (this.times > 3) { + this.times = 3 + } + } + + deltaX *= this.times + deltaY *= this.times + // if (this.props.axis !== 'x') { this.__BOX__.scrollTop += deltaY @@ -285,6 +300,7 @@ export default class Scroll { // 修正滚动条的位置 // 滚动比例 y 滚动条的可移动距离 var fixedY = (this.__BOX__.scrollTop / (sh - oh)) * (oh - yh) + fixedY = fixedY >> 0 if ( @@ -309,6 +325,7 @@ export default class Scroll { // 修正滚动条的位置 // 滚动比例 x 滚动条的可移动距离 var fixedX = (this.__BOX__.scrollLeft / (sw - ow)) * (ow - xw) + fixedX = fixedX >> 0 if ( @@ -326,6 +343,7 @@ export default class Scroll { } } + this.stamp = now this.dispatchEvent( new CustomEvent('scroll', { detail: { x: this.props.thumbX, y: this.props.thumbY }