'moves' are not 'taps'

This commit is contained in:
Gavin McDonald
2016-02-26 16:47:57 -05:00
parent 0e8d9019b5
commit 7bb085557e

View File

@@ -50,28 +50,61 @@ export default class OnTap {
console.log('mousedown', event); 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) { mouseup(event) {
if (this.state.clickStartTime) {
if (!this.state.moving) {
console.log('mouseup', event);
this.actions.tap.callback(event);
}
else {
console.log({ console.log({
duration: event.timeStamp - this.state.clickStartTime, duration: event.timeStamp - this.state.clickStartTime,
deltaX: event.pageX - this.state.clickStartX, deltaX: event.pageX - this.state.clickStartX,
deltaY: event.pageY - this.state.clickStartY 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.state.moving = null;
this.actions.tap.callback(event); 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) { mousemove(event) {
// console.log('mousemove', event);
if (this.state.clickStartTime) { if (this.state.clickStartTime) {
if (!this.state.moving) { 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) { touchmove(event) {
// console.log('touchmove', event);
if (this.state.clickStartTime) { if (this.state.clickStartTime) {
if (!this.state.moving) { if (!this.state.moving) {