pointerify
Advanced tools
Comparing version 0.3.1 to 0.3.2
{ | ||
"name": "pointerify", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"main": "./dist/pointerify.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
import Util from './Util'; | ||
import { | ||
AXIS_X, | ||
AXIS_Y, | ||
DIRECTION_STATIC, | ||
@@ -61,7 +63,7 @@ DIRECTION_LEFT, | ||
get deltaX() { | ||
return this.currentX - this.startX; | ||
return this.pointerify.config.behavior.allowAxis === AXIS_Y ? 0 : this.currentX - this.startX; | ||
} | ||
get deltaY() { | ||
return this.currentY - this.startY; | ||
return this.pointerify.config.behavior.allowAxis === AXIS_X ? 0 : this.currentY - this.startY; | ||
} | ||
@@ -94,7 +96,9 @@ | ||
get velocityX() { | ||
return this.velocitiesX.length ? this.velocitiesX.reduce((value, sum) => value + sum, 0) / this.velocitiesX.length : 0; | ||
return this.velocitiesX.length && this.pointerify.config.behavior.allowAxis !== AXIS_Y ? | ||
this.velocitiesX.reduce((value, sum) => value + sum, 0) / this.velocitiesX.length : 0; | ||
} | ||
get velocityY() { | ||
return this.velocitiesY.length ? this.velocitiesY.reduce((value, sum) => value + sum, 0) / this.velocitiesY.length : 0; | ||
return this.velocitiesY.length && this.pointerify.config.behavior.allowAxis !== AXIS_X ? | ||
this.velocitiesY.reduce((value, sum) => value + sum, 0) / this.velocitiesY.length : 0; | ||
} | ||
@@ -101,0 +105,0 @@ |
@@ -481,4 +481,6 @@ import { | ||
if (!pointer.isMoving) { | ||
const vector = Math.abs(pointer.deltaX / pointer.deltaY); | ||
// NB: Do not use deltas here as may report `0` | ||
const vector = Math.abs((pointer.currentX - pointer.startX) / (pointer.currentY - pointer.startY)); | ||
if (allowAxis === AXIS_X && vector < 1 || allowAxis === AXIS_Y && vector >= 1) { | ||
@@ -491,8 +493,2 @@ this.deletePointer(pointer); | ||
if (allowAxis === AXIS_X) { | ||
pointer.currentY = pointer.startY; | ||
} if (allowAxis === AXIS_Y) { | ||
pointer.currentX = pointer.startX; | ||
} | ||
if (pointer.isVirtualPointer && e === null) { | ||
@@ -499,0 +495,0 @@ pointer.status = POINTER_STATUS_STOPPING; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
214286
2949