滑动切换后,点击当前页面会回跳前一个项..怎么解决啊
Opened this issue · 1 comments
Deleted user commented
滑动切换后,点击当前页面会回跳前一个项..怎么解决啊
Clearave commented
handlerEnd(e) {
let {clientX, clientY} = e.changedTouches[0];
let endTime = e.timeStamp;
let {tabs, stv, activeTab} = this.data;
let {offset, windowWidth} = stv;
//快速滑动
if(endTime - this.tapStartTime <= 300) {
//向左
if(Math.abs(this.tapStartY - clientY) < 75) {
if(this.tapStartX - clientX > 5) {
if(activeTab < this.tabsCount -1) {
this.setData({activeTab: ++activeTab})
}
} else if (this.tapStartX - clientX < -5) {
if(activeTab > 0) {
this.setData({activeTab: --activeTab})
}
}
stv.offset = stv.windowWidth*activeTab;
} else {
//快速滑动 但是Y距离大于75 所以用户是左右滚动
let page = Math.round(offset/windowWidth);
if (activeTab != page) {
this.setData({activeTab: page})
}
stv.offset = stv.windowWidth*page;
}
} else {
let page = Math.round(offset/windowWidth);
if (activeTab != page) {
this.setData({activeTab: page})
}
stv.offset = stv.windowWidth*page;
}
stv.tStart = false;
this.setData({stv: this.data.stv})
},
这里else if 加个判断试试
else if (this.tapStartX - clientX < -5) {
if(activeTab > 0) {
this.setData({activeTab: --activeTab})
}
}
PS:
Math.abs(this.tapStartY - clientY) < 75
这个判断我自己改了,不影响这个issue的解决,我只是觉得50太敏感