微信小程序 页面滑动事件的实例详解

微信小程序——页面滑动事件

wxml:

rush:js;"> etouchtart" bindtouchmove="handletouchmove" bindtouchend="handletouchend" style = "width : 100%px; height : 40px;"> {{text}}

wxss:

rush:js;"> .ball { Box-shadow:2px 2px 10px #AAA; border-radius: 20px; position: absolute; }

js:

Math.abs(ty)) { if (tx < 0) text = "向左滑动" else if (tx > 0) text = "向右滑动" } //上下方向滑动 else { if (ty < 0) text = "向上滑动" else if (ty > 0) text = "向下滑动" }

//将当前坐标进行保存以进行下一次计算
this.data.lastX = currentX
this.data.lastY = currentY
this.setData({
text: text,});
},//滑动开始事件
handletouchtart: function (event) {
this.data.lastX = event.touches[0].pageX
this.data.lastY = event.touches[0].pageY
},//滑动结束事件
handletouchend: function (event) {
this.data.currentGesture = 0;
this.setData({
text: "没有滑动",})

如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持

相关文章

开发微信小程序的用户授权登录功能
小程序开发页面如何实现跳转?
浅谈小程序开发中蓝牙连接错误分析及解决方法
什么是小程序?它有哪些功能?
如何配置小程序开发项目结构?(教程)
怎么把自己的店加入小程序