From 020333d5b8b5c84eb9fffe1801b7aa2ae6056eb8 Mon Sep 17 00:00:00 2001 From: cuteCloud <348296106@qq.com> Date: Wed, 31 Oct 2018 17:05:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3index=E7=B4=A2=E5=BC=95?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=AD=98=E5=9C=A8=E7=9A=842=E4=B8=AAbug?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=8F=8A=E5=88=A0=E9=99=A4=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=A4=9A=E4=BD=99tap=E4=BA=8B=E4=BB=B6=EF=BC=9A1.=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E7=B4=A2=E5=BC=95=E9=A6=96=E4=BD=8D=E5=AD=97=E6=AF=8D?= =?UTF-8?q?=E5=AE=9A=E4=BD=8D=E4=B8=8D=E5=87=86=E7=A1=AE2.=E6=BB=91?= =?UTF-8?q?=E5=8A=A8=E8=B6=85=E5=87=BA=E8=BE=B9=E7=95=8C=E6=97=B6=E6=8A=A5?= =?UTF-8?q?=E9=94=993.=E5=88=A0=E9=99=A4=E7=B4=A2=E5=BC=95=E7=9A=84tap?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=EF=BC=8C=E5=9B=A0=E4=B8=BAcatchtouchstart,ca?= =?UTF-8?q?tchtouchend=E5=90=8E=E4=BA=8B=E4=BB=B6=E8=A2=AB=E9=98=BB?= =?UTF-8?q?=E6=AD=A2=E4=BA=86=EF=BC=8Ctap=E6=8D=95=E8=8E=B7=E4=B8=8D?= =?UTF-8?q?=E5=88=B0=EF=BC=8C=E7=94=A8=E5=B7=B2=E6=9C=89=E7=9A=84catchtouc?= =?UTF-8?q?hstart=E4=BB=A3=E6=9B=BF=E7=B4=A2=E5=BC=95=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E5=B0=B1=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/index/index.js | 20 +++++--------------- dist/index/index.wxml | 2 +- src/index/index.js | 20 +++++--------------- src/index/index.wxml | 2 +- 4 files changed, 12 insertions(+), 32 deletions(-) diff --git a/dist/index/index.js b/dist/index/index.js index c556f19..69a7ce8 100644 --- a/dist/index/index.js +++ b/dist/index/index.js @@ -99,26 +99,16 @@ Component({ triggerCallback(options){ this.triggerEvent('change',options) }, - handlerFixedTap(event){ - const eindex = event.currentTarget.dataset.index; - const item = this.getCurrentItem(eindex); - this.setData({ - scrollTop : item.top, - currentName : item.currentName, - isTouches : true - }) - this.triggerCallback({ - index : eindex, - current : item.currentName - }) - }, handlerTouchMove(event){ const data = this.data; 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; + if(index<0){ + return ; + } const movePosition = this.getCurrentItem(index); /* @@ -155,4 +145,4 @@ Component({ }).exec() } } -}) \ No newline at end of file +}) diff --git a/dist/index/index.wxml b/dist/index/index.wxml index f83d847..020b4c9 100644 --- a/dist/index/index.wxml +++ b/dist/index/index.wxml @@ -13,7 +13,7 @@ wx:for="{{fixedData}}" wx:key="{{index}}" data-index="{{index}}" - catchtap="handlerFixedTap"> + > {{item}} diff --git a/src/index/index.js b/src/index/index.js index c556f19..69a7ce8 100644 --- a/src/index/index.js +++ b/src/index/index.js @@ -99,26 +99,16 @@ Component({ triggerCallback(options){ this.triggerEvent('change',options) }, - handlerFixedTap(event){ - const eindex = event.currentTarget.dataset.index; - const item = this.getCurrentItem(eindex); - this.setData({ - scrollTop : item.top, - currentName : item.currentName, - isTouches : true - }) - this.triggerCallback({ - index : eindex, - current : item.currentName - }) - }, handlerTouchMove(event){ const data = this.data; 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; + if(index<0){ + return ; + } const movePosition = this.getCurrentItem(index); /* @@ -155,4 +145,4 @@ Component({ }).exec() } } -}) \ No newline at end of file +}) diff --git a/src/index/index.wxml b/src/index/index.wxml index f83d847..020b4c9 100644 --- a/src/index/index.wxml +++ b/src/index/index.wxml @@ -13,7 +13,7 @@ wx:for="{{fixedData}}" wx:key="{{index}}" data-index="{{index}}" - catchtap="handlerFixedTap"> + > {{item}}