<image bind:touchstart="onTouchStart" bindtouchmove="q5_onTouchMove" style="left: {{q5_tomato_left}}px; top: {{q5_tomato_top}}px;" src="cloud://cloud1-8gwgkldle8e2a93d.636c-cloud1-8gwgkldle8e2a93d-1324211457/fyss/tomato.png" />
onTouchStart(event) {
const touchX = event.touches[0].clientX;
const touchY = event.touches[0].clientY;
this.setData({
'positionLeft': touchX,
'positionTop': touchY
});
},
q5_onTouchMove (e) {
const q5_offsetX = e.touches[0].clientX - this.data.positionLeft;
const q5_offsetY = e.touches[0].clientY - this.data.positionTop;
const newX = this.data.q5_tomato_left + q5_offsetX;
const newY = this.data.q5_tomato_top + q5_offsetY;
this.setData({
q5_tomato_left: newX,
q5_tomato_top: newY,
positionLeft: e.touches[0].clientX,
positionTop: e.touches[0].clientY
});
},
为什么起始向上移动全程很丝滑,起始动作向下的话,全程有卡顿感?
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
建议用wxs事件来处理避免卡顿
https://developers.weixin.qq.com/miniprogram/dev/reference/wxs/
出个代码片段吧,我可以用我的手机帮你试试