Comparing version 2.2.1 to 2.3.0
{ | ||
"name": "unipointer", | ||
"version": "2.2.1", | ||
"version": "2.3.0", | ||
"description": "Do one thing with one pointer", | ||
@@ -5,0 +5,0 @@ "main": "unipointer.js", |
@@ -52,2 +52,2 @@ # Unipointer | ||
By [Metafizzy](http://metafizzy.co) | ||
By [Metafizzy](https://metafizzy.co) |
/*! | ||
* Unipointer v2.2.1 | ||
* Unipointer v2.3.0 | ||
* base class for doing one thing with pointer event | ||
@@ -53,18 +53,20 @@ * MIT license | ||
/** | ||
* works as unbinder, as you can ._bindStart( false ) to unbind | ||
* @param {Boolean} isBind - will unbind if falsey | ||
* Add or remove start event | ||
* @param {Boolean} isAdd - remove if falsey | ||
*/ | ||
proto._bindStartEvent = function( elem, isBind ) { | ||
// munge isBind, default to true | ||
isBind = isBind === undefined ? true : !!isBind; | ||
var bindMethod = isBind ? 'addEventListener' : 'removeEventListener'; | ||
proto._bindStartEvent = function( elem, isAdd ) { | ||
// munge isAdd, default to true | ||
isAdd = isAdd === undefined ? true : isAdd; | ||
var bindMethod = isAdd ? 'addEventListener' : 'removeEventListener'; | ||
// default to mouse events | ||
var startEvent = 'mousedown'; | ||
if ( window.PointerEvent ) { | ||
// Pointer Events. Chrome 55, IE11, Edge 14 | ||
elem[ bindMethod ]( 'pointerdown', this ); | ||
} else { | ||
// listen for both, for devices like Chrome Pixel | ||
elem[ bindMethod ]( 'mousedown', this ); | ||
elem[ bindMethod ]( 'touchstart', this ); | ||
// Pointer Events | ||
startEvent = 'pointerdown'; | ||
} else if ( 'ontouchstart' in window ) { | ||
// Touch Events. iOS Safari | ||
startEvent = 'touchstart'; | ||
} | ||
elem[ bindMethod ]( startEvent, this ); | ||
}; | ||
@@ -242,8 +244,11 @@ | ||
proto._pointerDone = function() { | ||
this._pointerReset(); | ||
this._unbindPostStartEvents(); | ||
this.pointerDone(); | ||
}; | ||
proto._pointerReset = function() { | ||
// reset properties | ||
this.isPointerDown = false; | ||
delete this.pointerIdentifier; | ||
// remove events | ||
this._unbindPostStartEvents(); | ||
this.pointerDone(); | ||
}; | ||
@@ -250,0 +255,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9267
280