From b83c247a02e7e307285bbb79da97ef8bfd6f52c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Sun, 2 Feb 2020 00:14:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E7=BB=84=E4=BB=B6=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=BB=9A=E5=8A=A8=E8=BD=B4=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scroll/index.wc | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/scroll/index.wc b/src/scroll/index.wc index 83ac9cd..cdca30e 100644 --- a/src/scroll/index.wc +++ b/src/scroll/index.wc @@ -214,7 +214,6 @@ export default class Scroll { this.props.xw = xw this.__X__.style.width = xw + 'px' - this.__Y__.style.height = yh + 'px' }) @@ -247,24 +246,30 @@ export default class Scroll { deltaY = ev.deltaY / (delta / 120) } } + if (this.props.axis !== 'x') { + this.__BOX__.scrollTop += deltaY - this.__BOX__.scrollTop += deltaY - this.__BOX__.scrollLeft += deltaX + if (yh) { + // 修正滚动条的位置 + // 滚动比例 y 滚动条的可移动距离 + var fixedY = (this.__BOX__.scrollTop / (sh - oh)) * (oh - yh) + this.props.thumbY = fixedY - if (xw) { - // 修正滚动条的位置 - // 滚动比例 x 滚动条的可移动距离 - var fixedX = (this.__BOX__.scrollLeft / (sw - ow)) * (ow - xw) - this.props.thumbX = fixedX - - this.__X__.style.transform = `translateX(${fixedX}px)` + this.__Y__.style.transform = `translateY(${fixedY}px)` + } } - if (yh) { - var fixedY = (this.__BOX__.scrollTop / (sh - oh)) * (oh - yh) - this.props.thumbY = fixedY + if (this.props.axis !== 'y') { + this.__BOX__.scrollLeft += deltaX - this.__Y__.style.transform = `translateY(${fixedY}px)` + if (xw) { + // 修正滚动条的位置 + // 滚动比例 x 滚动条的可移动距离 + var fixedX = (this.__BOX__.scrollLeft / (sw - ow)) * (ow - xw) + this.props.thumbX = fixedX + + this.__X__.style.transform = `translateX(${fixedX}px)` + } } })