touchmove 写拖动事件卡顿不流畅 |
您所在的位置:网站首页 › 微信小程序延迟 › touchmove 写拖动事件卡顿不流畅 |
页面上有个fixed悬浮按钮,希望可以在页面上任意拖动位置,但是现在的问题是写出来的拖动效果特别不流畅(反应延迟),请问有什么好的办法解决? js代码: setTouchMove:function(e){ var that = this; var width = 35 * rpx; var screenWidth = wx.getSystemInfoSync().windowWidth; var screenHeight = wx.getSystemInfoSync().windowHeight; var clientX = e.touches[0].clientX; var clientY = e.touches[0].clientY; //此处clientY与clientX为拖动悬浮窗超过设定的大小会返回默认显示位置 if (clientX < (screenWidth - width) && clientY < (screenHeight - width) && clientX > width && clientY > width) { that.setData({ right: screenWidth - clientX - width, bottom: screenHeight - clientY - width }) } else { return; // that.setData({ // right: 0, //默认显示位置 left距离 // bottom: 0 //默认显示位置 top距离 // }) } } |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |