mmenu-js
Advanced tools
Comparing version 8.4.4 to 8.4.5
{ | ||
"name" : "mmenu.js", | ||
"version" : "8.4.4", | ||
"version" : "8.4.5", | ||
"authors" : [{ | ||
@@ -5,0 +5,0 @@ "name" : "Fred Heusschen", |
@@ -31,2 +31,6 @@ import * as support from './_support'; | ||
DragEvents.prototype.start = function (event) { | ||
this.currentPosition = { | ||
x: event.touches ? event.touches[0].pageX : event.pageX || 0, | ||
y: event.touches ? event.touches[0].pageY : event.pageY || 0 | ||
}; | ||
/** The widht of the surface. */ | ||
@@ -39,3 +43,3 @@ var width = this.surface.clientWidth; | ||
if (typeof top == 'number') { | ||
if (event.pageY < top) { | ||
if (this.currentPosition.y < top) { | ||
return; | ||
@@ -48,3 +52,3 @@ } | ||
right = width - right; | ||
if (event.pageX > right) { | ||
if (this.currentPosition.x > right) { | ||
return; | ||
@@ -57,3 +61,3 @@ } | ||
bottom = height - bottom; | ||
if (event.pageY > bottom) { | ||
if (this.currentPosition.y > bottom) { | ||
return; | ||
@@ -65,3 +69,3 @@ } | ||
if (typeof left == 'number') { | ||
if (event.pageX < left) { | ||
if (this.currentPosition.x < left) { | ||
return; | ||
@@ -72,4 +76,4 @@ } | ||
this.startPosition = { | ||
x: event.pageX, | ||
y: event.pageY | ||
x: this.currentPosition.x, | ||
y: this.currentPosition.y | ||
}; | ||
@@ -110,10 +114,22 @@ // Set the state of the gesture to "watching". | ||
case settings.state.dragging: | ||
var position = { | ||
x: event.changedTouches | ||
? event.touches[0].pageX | ||
: event.pageX || 0, | ||
y: event.changedTouches | ||
? event.touches[0].pageY | ||
: event.pageY || 0 | ||
}; | ||
this.movement = { | ||
x: event.movementX, | ||
y: event.movementY | ||
x: position.x - this.currentPosition.x, | ||
y: position.y - this.currentPosition.y | ||
}; | ||
this.distance = { | ||
x: event.pageX - this.startPosition.x, | ||
y: event.pageY - this.startPosition.y | ||
x: position.x - this.startPosition.x, | ||
y: position.y - this.startPosition.y | ||
}; | ||
this.currentPosition = { | ||
x: position.x, | ||
y: position.y | ||
}; | ||
this.axis = | ||
@@ -120,0 +136,0 @@ Math.abs(this.distance.x) > Math.abs(this.distance.y) |
@@ -1,1 +0,1 @@ | ||
export default '8.4.4'; | ||
export default '8.4.5'; |
{ | ||
"name": "mmenu-js", | ||
"version": "8.4.4", | ||
"version": "8.4.5", | ||
"main": "dist/mmenu.js", | ||
@@ -5,0 +5,0 @@ "module": "src/mmenu.js", |
@@ -20,2 +20,5 @@ import * as support from './_support'; | ||
/** The last measured x- and y- position. */ | ||
currentPosition: dragCoordinates; | ||
/** The dragged x- and y-distances since the start. */ | ||
@@ -76,2 +79,7 @@ distance: dragCoordinates; | ||
start(event) { | ||
this.currentPosition = { | ||
x: event.touches ? event.touches[0].pageX : event.pageX || 0, | ||
y: event.touches ? event.touches[0].pageY : event.pageY || 0 | ||
}; | ||
/** The widht of the surface. */ | ||
@@ -86,3 +94,3 @@ var width = this.surface.clientWidth; | ||
if (typeof top == 'number') { | ||
if (event.pageY < top) { | ||
if (this.currentPosition.y < top) { | ||
return; | ||
@@ -96,3 +104,3 @@ } | ||
right = width - right; | ||
if (event.pageX > right) { | ||
if (this.currentPosition.x > right) { | ||
return; | ||
@@ -106,3 +114,3 @@ } | ||
bottom = height - bottom; | ||
if (event.pageY > bottom) { | ||
if (this.currentPosition.y > bottom) { | ||
return; | ||
@@ -115,3 +123,3 @@ } | ||
if (typeof left == 'number') { | ||
if (event.pageX < left) { | ||
if (this.currentPosition.x < left) { | ||
return; | ||
@@ -123,4 +131,4 @@ } | ||
this.startPosition = { | ||
x: event.pageX, | ||
y: event.pageY | ||
x: this.currentPosition.x, | ||
y: this.currentPosition.y | ||
}; | ||
@@ -169,12 +177,26 @@ | ||
case settings.state.dragging: | ||
var position = { | ||
x: event.changedTouches | ||
? event.touches[0].pageX | ||
: event.pageX || 0, | ||
y: event.changedTouches | ||
? event.touches[0].pageY | ||
: event.pageY || 0 | ||
}; | ||
this.movement = { | ||
x: event.movementX, | ||
y: event.movementY | ||
x: position.x - this.currentPosition.x, | ||
y: position.y - this.currentPosition.y | ||
}; | ||
this.distance = { | ||
x: event.pageX - this.startPosition.x, | ||
y: event.pageY - this.startPosition.y | ||
x: position.x - this.startPosition.x, | ||
y: position.y - this.startPosition.y | ||
}; | ||
this.currentPosition = { | ||
x: position.x, | ||
y: position.y | ||
}; | ||
this.axis = | ||
@@ -181,0 +203,0 @@ Math.abs(this.distance.x) > Math.abs(this.distance.y) |
@@ -1,1 +0,1 @@ | ||
export default '8.4.4'; | ||
export default '8.4.5'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
779230
13924