From 36feda623db9dc30eb4ef64277be4561a31ea47f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Wed, 26 May 2021 11:58:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=94=B1=E4=BA=8E=E6=9C=AA?= =?UTF-8?q?=E7=9F=A5=E5=8E=9F=E5=9B=A0,=E5=AF=BC=E8=87=B4=E7=88=B6?= =?UTF-8?q?=E5=AE=B9=E5=99=A8=E4=BA=A7=E7=94=9F=E6=BB=9A=E5=8A=A8=E8=B7=9D?= =?UTF-8?q?=E7=A6=BB=E5=AF=BC=E8=87=B4=E7=9A=84=E5=86=85=E5=AE=B9=E8=A2=AB?= =?UTF-8?q?=E9=81=AE=E6=8C=A1=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scroll/index.wc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/scroll/index.wc b/src/scroll/index.wc index e59e6b1..8583d6c 100644 --- a/src/scroll/index.wc +++ b/src/scroll/index.wc @@ -240,12 +240,16 @@ export default class Scroll { // 初始化滚动条的位置和长度 this._initFn = ev => { // 需要减去因为隐藏原生滚动条修正的18像素 - var width = this.offsetWidth - var height = this.offsetHeight - var scrollWidth = this.__BOX__.scrollWidth - 18 - var scrollHeight = this.__BOX__.scrollHeight - 18 - var yBar = (height * (height / scrollHeight)) >> 0 // 滚动条的高度 - var xBar = (width * (width / scrollWidth)) >> 0 // 滚动条的宽度 + let width = this.offsetWidth + let height = this.offsetHeight + let scrollWidth = this.__BOX__.scrollWidth - 18 + let scrollHeight = this.__BOX__.scrollHeight - 18 + let yBar = (height * (height / scrollHeight)) >> 0 // 滚动条的高度 + let xBar = (width * (width / scrollWidth)) >> 0 // 滚动条的宽度 + + // 修正由于未知原因,导致父容器产生滚动距离 + // 导致的内容被遮挡的bug + this.__BOX__.parentNode.scrollTop = 0 // 修复因为内容的margin导致滚动条取值不准确的bug if (this.__BOX__.clientHeight - height !== 18) {