tap-listener
Advanced tools
Comparing version 1.1.2 to 2.0.0
{ | ||
"name": "tap-listener", | ||
"main": "tap-listener.js", | ||
"version": "1.1.2", | ||
"dependencies": { | ||
"unipointer": "~1.1.0" | ||
"unipointer": "^2.1.0" | ||
}, | ||
@@ -8,0 +7,0 @@ "authors": [ |
{ | ||
"name": "tap-listener", | ||
"version": "1.1.2", | ||
"version": "2.0.0", | ||
"description": "Listens to taps", | ||
"main": "tap-listener.js", | ||
"dependencies": { | ||
"unipointer": "~1.1.0" | ||
"unipointer": "^2.1.0" | ||
}, | ||
@@ -9,0 +9,0 @@ "devDependencies": {}, |
/*! | ||
* Tap listener v1.1.2 | ||
* Tap listener v2.0.0 | ||
* listens to taps | ||
@@ -20,3 +20,3 @@ * MIT license | ||
}); | ||
} else if ( typeof exports == 'object' ) { | ||
} else if ( typeof module == 'object' && module.exports ) { | ||
// CommonJS | ||
@@ -46,3 +46,3 @@ module.exports = factory( | ||
// inherit Unipointer & EventEmitter | ||
TapListener.prototype = new Unipointer(); | ||
var proto = TapListener.prototype = Object.create( Unipointer.prototype ); | ||
@@ -53,3 +53,3 @@ /** | ||
*/ | ||
TapListener.prototype.bindTap = function( elem ) { | ||
proto.bindTap = function( elem ) { | ||
if ( !elem ) { | ||
@@ -63,3 +63,3 @@ return; | ||
TapListener.prototype.unbindTap = function() { | ||
proto.unbindTap = function() { | ||
if ( !this.tapElement ) { | ||
@@ -72,3 +72,2 @@ return; | ||
var isPageOffset = window.pageYOffset !== undefined; | ||
/** | ||
@@ -79,3 +78,3 @@ * pointer up | ||
*/ | ||
TapListener.prototype.pointerUp = function( event, pointer ) { | ||
proto.pointerUp = function( event, pointer ) { | ||
// ignore emulated mouse up clicks | ||
@@ -88,5 +87,4 @@ if ( this.isIgnoringMouseUp && event.type == 'mouseup' ) { | ||
var boundingRect = this.tapElement.getBoundingClientRect(); | ||
// standard or IE8 scroll positions | ||
var scrollX = isPageOffset ? window.pageXOffset : document.body.scrollLeft; | ||
var scrollY = isPageOffset ? window.pageYOffset : document.body.scrollTop; | ||
var scrollX = window.pageXOffset; | ||
var scrollY = window.pageYOffset; | ||
// calculate if pointer is inside tapElement | ||
@@ -106,9 +104,10 @@ var isInside = pointerPoint.x >= boundingRect.left + scrollX && | ||
// reset flag after 300ms | ||
var _this = this; | ||
setTimeout( function() { | ||
delete this.isIgnoringMouseUp; | ||
}.bind( this ), 320 ); | ||
delete _this.isIgnoringMouseUp; | ||
}, 400 ); | ||
} | ||
}; | ||
TapListener.prototype.destroy = function() { | ||
proto.destroy = function() { | ||
this.pointerDone(); | ||
@@ -115,0 +114,0 @@ this.unbindTap(); |
5462
128
+ Addedev-emitter@1.1.1(transitive)
+ Addedunipointer@2.4.0(transitive)
- Removedeventie@1.0.6(transitive)
- Removedunipointer@1.1.0(transitive)
- Removedwolfy87-eventemitter@4.2.11(transitive)
Updatedunipointer@^2.1.0