'moves' are not 'taps'
This commit is contained in:
70
src/onTap.js
70
src/onTap.js
@@ -50,13 +50,29 @@ 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.moving = null;
|
||||||
this.state.lastX = null;
|
this.state.lastX = null;
|
||||||
@@ -66,12 +82,29 @@ export default class OnTap {
|
|||||||
this.state.clickStartTime = null;
|
this.state.clickStartTime = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('mouseup', event);
|
touchend(event) {
|
||||||
|
|
||||||
|
if (!this.state.moving) {
|
||||||
|
console.log('touchend', event);
|
||||||
this.actions.tap.callback(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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user