Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions dist/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/*
Expand Down Expand Up @@ -155,4 +145,4 @@ Component({
}).exec()
}
}
})
})
2 changes: 1 addition & 1 deletion dist/index/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
wx:for="{{fixedData}}"
wx:key="{{index}}"
data-index="{{index}}"
catchtap="handlerFixedTap">
>
{{item}}
</view>
</view>
Expand Down
20 changes: 5 additions & 15 deletions src/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/*
Expand Down Expand Up @@ -155,4 +145,4 @@ Component({
}).exec()
}
}
})
})
2 changes: 1 addition & 1 deletion src/index/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
wx:for="{{fixedData}}"
wx:key="{{index}}"
data-index="{{index}}"
catchtap="handlerFixedTap">
>
{{item}}
</view>
</view>
Expand Down