1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| touchStart: function (e) { this.setData({ touchStartTime: e.timeStamp, touchFlag: true }); }, tapJudgement: function (e) { let that = this; that.setData({ touchEndTime: e.timeStamp, }); if (that.data.touchStartTime === null && that.data.touchEndTime === null) { return; } let gap = that.data.touchEndTime - that.data.touchStartTime; if (Math.abs(gap) < 350) { let currentTapTime = e.timeStamp; let lastTapTime = that.data.lastTapTime; that.setData({ lastTapTime: currentTapTime }); if (currentTapTime - lastTapTime < 300 && lastTapTime !== null) { //double tap event clearTimeout(that.data.lastTapTimeoutFunc); wx.showToast({ title: 'double tap event', }); } else { let timer = setTimeout(function () { wx.showToast({ title: 'single tap event', }); }, 300); that.setData({ lastTapTimeoutFunc: timer }); } } }, longpressHandle: function (e) { wx.showToast({ title: 'Trigger long press event', }); this.setData({ touchEndTime: e.timeStamp }); }
|