From 7bb085557e80eefe153c76703750e6e5bcad8581 Mon Sep 17 00:00:00 2001 From: Gavin McDonald Date: Fri, 26 Feb 2016 16:47:57 -0500 Subject: [PATCH] 'moves' are not 'taps' --- src/onTap.js | 86 +++++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/src/onTap.js b/src/onTap.js index 73c330f..76c0010 100644 --- a/src/onTap.js +++ b/src/onTap.js @@ -50,28 +50,61 @@ export default class OnTap { console.log('mousedown', event); } + touchstart(event) { + if (!this.state.clickStartTime) { + this.state.clickStartX = event.pageX; + this.state.clickStartY = event.pageY; + this.state.clickStartTime = event.timeStamp; + } + + console.log('touchstart', event); + } + mouseup(event) { - if (this.state.clickStartTime) { + + if (!this.state.moving) { + console.log('mouseup', event); + this.actions.tap.callback(event); + } + else { console.log({ duration: event.timeStamp - this.state.clickStartTime, deltaX: event.pageX - this.state.clickStartX, deltaY: event.pageY - this.state.clickStartY }); - - this.state.moving = null; - this.state.lastX = null; - this.state.lastY = null; - this.state.clickStartX = null; - this.state.clickStartY = null; - this.state.clickStartTime = null; } - console.log('mouseup', event); - this.actions.tap.callback(event); + this.state.moving = null; + this.state.lastX = null; + this.state.lastY = null; + this.state.clickStartX = null; + this.state.clickStartY = null; + this.state.clickStartTime = null; + } + + touchend(event) { + + if (!this.state.moving) { + console.log('touchend', event); + this.actions.tap.callback(event); + } + else { + console.log({ + duration: event.timeStamp - this.state.clickStartTime, + deltaX: event.pageX - this.state.clickStartX, + deltaY: event.pageY - this.state.clickStartY + }); + } + + this.state.moving = null; + this.state.lastX = null; + this.state.lastY = null; + this.state.clickStartX = null; + this.state.clickStartY = null; + this.state.clickStartTime = null; } mousemove(event) { -// console.log('mousemove', event); if (this.state.clickStartTime) { if (!this.state.moving) { @@ -94,38 +127,7 @@ export default class OnTap { } } - touchstart(event) { - if (!this.state.clickStartTime) { - this.state.clickStartX = event.pageX; - this.state.clickStartY = event.pageY; - this.state.clickStartTime = event.timeStamp; - } - - console.log('touchstart', event); - } - - touchend(event) { - if (this.state.clickStartTime) { - console.log({ - duration: event.timeStamp - this.state.clickStartTime, - deltaX: event.pageX - this.state.clickStartX, - deltaY: event.pageY - this.state.clickStartY - }); - - this.state.moving = null; - this.state.lastX = null; - this.state.lastY = null; - this.state.clickStartX = null; - this.state.clickStartY = null; - this.state.clickStartTime = null; - } - - console.log('touchend', event); - this.actions.tap.callback(event); - } - touchmove(event) { -// console.log('touchmove', event); if (this.state.clickStartTime) { if (!this.state.moving) {