From ce2f685f43f0f9a88a7dc2dede7dff80b2272861 Mon Sep 17 00:00:00 2001 From: ChrisChen <309129685@qq.com> Date: Wed, 8 May 2019 16:11:08 +0800 Subject: [PATCH] =?UTF-8?q?1.=20fix=20=20=E4=BF=AE=E5=A4=8D'index=20?= =?UTF-8?q?=E7=B4=A2=E5=BC=95=E9=80=89=E6=8B=A9=E5=99=A8'=20=E5=AD=97?= =?UTF-8?q?=E6=AF=8D=E7=82=B9=E5=87=BB=E5=81=8F=E5=B7=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 复现操作:点击A会显示B,点击B会显示C,以此类推 --- dist/index/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/index/index.js b/dist/index/index.js index c556f19..2690a9a 100644 --- a/dist/index/index.js +++ b/dist/index/index.js @@ -52,7 +52,7 @@ Component({ timer : null }) } - + this.data.timer = setTimeout(()=>{ const data = []; indexItems.forEach((item) => { @@ -71,7 +71,7 @@ Component({ this.setData({ timer : this.data.timer }) - + } }, handlerScroll(event){ @@ -117,7 +117,7 @@ Component({ const touches = event.touches[0] || {}; const pageY = touches.pageY; const rest = pageY - data.startTop; - let index = Math.ceil( rest/data.itemHeight ); + let index = Math.floor( rest/data.itemHeight ); index = index >= data.itemLength ? data.itemLength -1 : index; const movePosition = this.getCurrentItem(index); @@ -155,4 +155,4 @@ Component({ }).exec() } } -}) \ No newline at end of file +})