Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@odopod/odo-pointer

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@odopod/odo-pointer - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

38

dist/odo-pointer.js

@@ -86,4 +86,2 @@ (function (global, factory) {

var babelHelpers = {};
var classCallCheck = function (instance, Constructor) {

@@ -113,2 +111,10 @@ if (!(instance instanceof Constructor)) {

var inherits = function (subClass, superClass) {

@@ -130,2 +136,12 @@ if (typeof superClass !== "function" && superClass !== null) {

var possibleConstructorReturn = function (self, call) {

@@ -139,6 +155,2 @@ if (!self) {

babelHelpers;
function isXAxis(axis) {

@@ -161,3 +173,3 @@ return axis === settings.Axis.X;

function finiteOrZero(velocity) {
return isFinite(velocity) ? velocity : 0;
return Number.isFinite(velocity) ? velocity : 0;
}

@@ -1017,3 +1029,3 @@

if (Pointer.isTouchEvent(evt)) {
pagePoints = evt.changedTouches[0];
pagePoints = evt.changedTouches[0]; // eslint-disable-line prefer-destructuring
} else {

@@ -1032,3 +1044,3 @@ pagePoints = evt;

key: 'element',
get: function get() {
get: function get$$1() {
return this._el;

@@ -1044,3 +1056,3 @@ }

key: 'isEnabled',
get: function get() {
get: function get$$1() {
return this._enabled;

@@ -1054,3 +1066,3 @@ }

,
set: function set(enabled) {
set: function set$$1(enabled) {
this._enabled = enabled;

@@ -1060,3 +1072,3 @@ }

key: 'friction',
get: function get() {
get: function get$$1() {
return this._friction;

@@ -1070,3 +1082,3 @@ }

,
set: function set(friction) {
set: function set$$1(friction) {
this._friction = friction;

@@ -1073,0 +1085,0 @@ }

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("tiny-emitter"),require("@odopod/odo-device"),require("@odopod/odo-helpers")):"function"==typeof define&&define.amd?define(["tiny-emitter","@odopod/odo-device","@odopod/odo-helpers"],e):t.OdoPointer=e(t.TinyEmitter,t.OdoDevice,t.OdoHelpers)}(this,function(t,e,i){"use strict";function n(t){return t===p.Axis.X}function s(t){return t===p.Axis.Y}function o(t){return t===p.Axis.BOTH}function r(t){return t!==p.Direction.NONE}function a(t){return isFinite(t)?t:0}function h(t,e,n){return new i.Coordinate(a(e/t),a(n/t))}function c(t,e,i,n,s){return t-e>0?i:t-e<0?n:s}function d(t,e){return Math.abs(t.x-e.x)>=Math.abs(t.y-e.y)?c(t.x,e.x,p.Direction.LEFT,p.Direction.RIGHT,p.Direction.NONE):c(t.y,e.y,p.Direction.UP,p.Direction.DOWN,p.Direction.NONE)}function u(t,e){var i=n(t)&&(e===p.Direction.LEFT||e===p.Direction.RIGHT),a=s(t)&&(e===p.Direction.UP||e===p.Direction.DOWN),h=o(t)&&r(e);return i||a||h}function v(t,e,i,a){return n(t)&&Math.abs(i)>0||s(t)&&Math.abs(a)>0||o(t)&&r(e)}function l(t,e,i){var o=Object.assign({},e),r=Object.assign({},i);return n(t)?(o.y=0,r.y=0):s(t)&&(o.x=0,r.x=0),d(o,r)}t=t&&t.hasOwnProperty("default")?t.default:t;var p={EventType:{START:"odopointer:start",MOVE:"odopointer:move",END:"odopointer:end"},Direction:{RIGHT:"right",LEFT:"left",UP:"up",DOWN:"down",NONE:"no_movement"},TouchActionSupport:{x:(e=e&&e.hasOwnProperty("default")?e.default:e).prefixed("touchAction","pan-y"),y:e.prefixed("touchAction","pan-x"),xy:e.prefixed("touchAction","none")},TouchAction:{x:"pan-y",y:"pan-x",xy:"none"},Axis:{X:"x",Y:"y",BOTH:"xy"},Defaults:{axis:"xy",preventEventDefault:!0},MAX_VELOCITY:12,VELOCITY_INTERVAL:100,SWIPE_VELOCITY:.6,LOCK_THRESHOLD:6,DRAG_THRESHOLD:5},_=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},E=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),f=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},T=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},y=function(){function t(e){_(this,t),this.type=e.type,this.target=e.target,this.currentTarget=e.currentTarget,this.start=e.start,this.end=e.end,this.delta=e.delta,this.deltaTime=e.deltaTime,this.velocity=h(this.deltaTime,this.delta.x,this.delta.y),this.currentVelocity=e.currentVelocity,this.distance=i.Coordinate.distance(e.start,e.end),this.direction=d(e.start,e.end),this.isDirectionOnAxis=u(e.axis,this.direction),this.didMoveOnAxis=v(e.axis,this.direction,this.delta.x,this.delta.y),this.axisDirection=l(e.axis,e.start,e.end),this.position=e.position,this.defaultPrevented=!1}return t.prototype.preventDefault=function(){this.defaultPrevented=!0},t}(),D=function(t){function n(s){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_(this,n);var r=T(this,t.call(this));if(!s||1!==s.nodeType)throw new TypeError("OdoPointer requires an element.");var a=Object.assign({},n.Defaults,o);r._shouldPreventDefault=a.preventEventDefault,r._el=s,r.pageStart=new i.Coordinate,r.page=new i.Coordinate,r.delta=new i.Coordinate,r._lastPosition=new i.Coordinate,r._friction=1,r.axis=a.axis,r.hasDragged=!1,r._isLocked=!1,r._isDeactivated=!1,r._enabled=!0,r._velocityTrackerId=null,r.startTime=0,r.deltaTime=0,r._lastTime=0,r.velocity=new i.Coordinate,r._hasTrackedVelocity=!1,r.dragEventTarget=document;var h=n.TouchActionSupport[r.axis];return r._isTouchActionSupported=!!h,r._shouldPreventDefault&&r._isTouchActionSupported?r.element.style[h]=n.TouchAction[r.axis]:r._shouldPreventDefault&&e.HAS_TOUCH_EVENTS&&window.addEventListener(i.events.TOUCHMOVE,i.utilities.noop),r.listen(),r}return f(n,t),n.prototype.listen=function(){this._onStart=this._handleDragStart.bind(this),e.HAS_POINTER_EVENTS?this._el.addEventListener(i.events.POINTERDOWN,this._onStart):(this._el.addEventListener(i.events.MOUSEDOWN,this._onStart),e.HAS_TOUCH_EVENTS&&this._el.addEventListener(i.events.TOUCHSTART,this._onStart)),this._el.addEventListener(i.events.DRAGSTART,n._preventDefault)},n.prototype.isXAxis=function(){return this.axis===n.Axis.X},n.prototype.isYAxis=function(){return this.axis===n.Axis.Y},n.prototype.isBothAxis=function(){return this.axis===n.Axis.BOTH},n.prototype.applyFriction=function(t){return t.scale(this.friction)},n.prototype._canStartDrag=function(t){return this.isEnabled&&(n.isTouchEvent(t)||0===t.button)},n.prototype._canContinueDrag=function(){return this.isEnabled&&!this._isDeactivated},n.prototype._handleDragStart=function(t){clearInterval(this._velocityTrackerId),this._canStartDrag(t)&&(this._setDragStartValues(n._getPageCoordinate(t)),this._emitEvent(this._createEvent(n.EventType.START,t))||(this._addDragHandlers(t.type),this._velocityTrackerId=setInterval(this._trackVelocity.bind(this),n.VELOCITY_INTERVAL)))},n.prototype._handleDragMove=function(t){this._canContinueDrag()&&(this._setDragMoveValues(n._getPageCoordinate(t)),this._emitEvent(this._createEvent(n.EventType.MOVE,t))||!this._shouldPreventDefault||this._isTouchActionSupported||this._finishDragMove(t))},n.prototype._finishDragMove=function(t){this._maybeLock(),this._maybeDeactivate(),this._isLocked&&t.preventDefault(),this._isDeactivated&&(clearInterval(this._velocityTrackerId),this.velocity.x=0,this.velocity.y=0)},n.prototype._handleDragEnd=function(t){clearInterval(this._velocityTrackerId),this.deltaTime=Date.now()-this.startTime,this._hasTrackedVelocity||this._trackVelocity(),this._removeDragHandlers();var e=this._createEvent(n.EventType.END,t);e.isCancelEvent=n._isCancelEvent(t),this._emitEvent(e)&&t.preventDefault(),this.hasDragged=!1,this._isDeactivated=!1,this._isLocked=!1},n.prototype._setDragStartValues=function(t){this.pageStart=t,this.page=t,this._lastPosition=t,this.delta=new i.Coordinate,this.velocity=new i.Coordinate,this._hasTrackedVelocity=!1,this.startTime=Date.now(),this._lastTime=Date.now(),this.deltaTime=0},n.prototype._setDragMoveValues=function(t){var e=i.Coordinate.difference(t,this.page);this.applyFriction(e),this.delta.translate(e),this.page=t,this.deltaTime=Date.now()-this.startTime,this.hasDragged=!0},n.prototype._maybeLock=function(){this._isLocked||(this._isLocked=this._shouldLock(this.delta))},n.prototype._maybeDeactivate=function(){this._isDeactivated||(this._isDeactivated=this._shouldDeactivate(this.delta))},n.prototype._shouldLock=function(t){var e=this.isXAxis()&&Math.abs(t.x)>n.LOCK_THRESHOLD,i=this.isYAxis()&&Math.abs(t.y)>n.LOCK_THRESHOLD;return this.isBothAxis()||e||i},n.prototype._shouldDeactivate=function(t){var e=this.isXAxis()&&Math.abs(t.y)>n.DRAG_THRESHOLD,i=this.isYAxis()&&Math.abs(t.x)>n.DRAG_THRESHOLD;return!this._isLocked&&(this.isBothAxis()||e||i)},n.prototype._createEvent=function(t,e){return new n.Event({type:t,pointerId:this.id,currentTarget:this.element,target:e.target,axis:this.axis,deltaTime:this.deltaTime,delta:this.delta,start:this.pageStart,end:this.page,currentVelocity:this.velocity})},n.prototype._addDragHandlers=function(t){var e=this.dragEventTarget;switch(this._onMove=this._handleDragMove.bind(this),this._onEnd=this._handleDragEnd.bind(this),t){case i.events.POINTERDOWN:e.addEventListener(i.events.POINTERMOVE,this._onMove),e.addEventListener(i.events.POINTERUP,this._onEnd),e.addEventListener(i.events.POINTERCANCEL,this._onEnd);break;case i.events.MOUSEDOWN:e.addEventListener(i.events.MOUSEMOVE,this._onMove),e.addEventListener(i.events.MOUSEUP,this._onEnd);break;case i.events.TOUCHSTART:e.addEventListener(i.events.TOUCHMOVE,this._onMove),e.addEventListener(i.events.TOUCHEND,this._onEnd),e.addEventListener(i.events.TOUCHCANCEL,this._onEnd)}},n.prototype._removeDragHandlers=function(){var t=this.dragEventTarget;t.removeEventListener(i.events.POINTERMOVE,this._onMove),t.removeEventListener(i.events.POINTERUP,this._onEnd),t.removeEventListener(i.events.POINTERCANCEL,this._onEnd),t.removeEventListener(i.events.MOUSEMOVE,this._onMove),t.removeEventListener(i.events.MOUSEUP,this._onEnd),t.removeEventListener(i.events.TOUCHMOVE,this._onMove),t.removeEventListener(i.events.TOUCHEND,this._onEnd),t.removeEventListener(i.events.TOUCHCANCEL,this._onEnd)},n.prototype._trackVelocity=function(){var t=Date.now(),e=t-this._lastTime,s=i.Coordinate.difference(this.page,this._lastPosition);this.applyFriction(s),this._lastTime=t,this._lastPosition=this.page;var o=n.MAX_VELOCITY;this.velocity.x=i.math.clamp(s.x/e,-o,o),this.velocity.y=i.math.clamp(s.y/e,-o,o),this._hasTrackedVelocity=!0},n.prototype.hasVelocity=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.SWIPE_VELOCITY;return this.isYAxis()?Math.abs(t.y)>e:this.isXAxis()?Math.abs(t.x)>e:Math.abs(t.x)>e||Math.abs(t.y)>e},n.prototype._emitEvent=function(t){return this.emit(t.type,t),t.defaultPrevented},n.prototype.dispose=function(){clearInterval(this._velocityTrackerId),this._removeDragHandlers(),this._el.removeEventListener(i.events.POINTERDOWN,this._onStart),this._el.removeEventListener(i.events.MOUSEDOWN,this._onStart),this._el.removeEventListener(i.events.TOUCHSTART,this._onStart),this._isTouchActionSupported?this._el.style[n.TouchActionSupport[this.axis]]="":this._shouldPreventDefault&&e.HAS_TOUCH_EVENTS&&window.removeEventListener(i.events.TOUCHMOVE,i.utilities.noop),this._el=null,this.dragEventTarget=null},n.isTouchEvent=function(t){return!!t.changedTouches},n._isCancelEvent=function(t){return t.type===i.events.POINTERCANCEL||t.type===i.events.TOUCHCANCEL},n._getPageCoordinate=function(t){var e=void 0;return e=n.isTouchEvent(t)?t.changedTouches[0]:t,new i.Coordinate(e.pageX,e.pageY)},n._preventDefault=function(t){t.preventDefault()},E(n,[{key:"element",get:function(){return this._el}},{key:"isEnabled",get:function(){return this._enabled},set:function(t){this._enabled=t}},{key:"friction",get:function(){return this._friction},set:function(t){this._friction=t}}]),n}(t);return Object.assign(D,p),D.Event=y,D});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("tiny-emitter"),require("@odopod/odo-device"),require("@odopod/odo-helpers")):"function"==typeof define&&define.amd?define(["tiny-emitter","@odopod/odo-device","@odopod/odo-helpers"],e):t.OdoPointer=e(t.TinyEmitter,t.OdoDevice,t.OdoHelpers)}(this,function(t,e,i){"use strict";function n(t){return t===p.Axis.X}function s(t){return t===p.Axis.Y}function o(t){return t===p.Axis.BOTH}function r(t){return t!==p.Direction.NONE}function a(t){return Number.isFinite(t)?t:0}function h(t,e,n){return new i.Coordinate(a(e/t),a(n/t))}function c(t,e,i,n,s){return t-e>0?i:t-e<0?n:s}function d(t,e){return Math.abs(t.x-e.x)>=Math.abs(t.y-e.y)?c(t.x,e.x,p.Direction.LEFT,p.Direction.RIGHT,p.Direction.NONE):c(t.y,e.y,p.Direction.UP,p.Direction.DOWN,p.Direction.NONE)}function u(t,e){var i=n(t)&&(e===p.Direction.LEFT||e===p.Direction.RIGHT),a=s(t)&&(e===p.Direction.UP||e===p.Direction.DOWN),h=o(t)&&r(e);return i||a||h}function v(t,e,i,a){return n(t)&&Math.abs(i)>0||s(t)&&Math.abs(a)>0||o(t)&&r(e)}function l(t,e,i){var o=Object.assign({},e),r=Object.assign({},i);return n(t)?(o.y=0,r.y=0):s(t)&&(o.x=0,r.x=0),d(o,r)}t=t&&t.hasOwnProperty("default")?t.default:t;var p={EventType:{START:"odopointer:start",MOVE:"odopointer:move",END:"odopointer:end"},Direction:{RIGHT:"right",LEFT:"left",UP:"up",DOWN:"down",NONE:"no_movement"},TouchActionSupport:{x:(e=e&&e.hasOwnProperty("default")?e.default:e).prefixed("touchAction","pan-y"),y:e.prefixed("touchAction","pan-x"),xy:e.prefixed("touchAction","none")},TouchAction:{x:"pan-y",y:"pan-x",xy:"none"},Axis:{X:"x",Y:"y",BOTH:"xy"},Defaults:{axis:"xy",preventEventDefault:!0},MAX_VELOCITY:12,VELOCITY_INTERVAL:100,SWIPE_VELOCITY:.6,LOCK_THRESHOLD:6,DRAG_THRESHOLD:5},_=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},E=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),f=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},T=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},y=function(){function t(e){_(this,t),this.type=e.type,this.target=e.target,this.currentTarget=e.currentTarget,this.start=e.start,this.end=e.end,this.delta=e.delta,this.deltaTime=e.deltaTime,this.velocity=h(this.deltaTime,this.delta.x,this.delta.y),this.currentVelocity=e.currentVelocity,this.distance=i.Coordinate.distance(e.start,e.end),this.direction=d(e.start,e.end),this.isDirectionOnAxis=u(e.axis,this.direction),this.didMoveOnAxis=v(e.axis,this.direction,this.delta.x,this.delta.y),this.axisDirection=l(e.axis,e.start,e.end),this.position=e.position,this.defaultPrevented=!1}return t.prototype.preventDefault=function(){this.defaultPrevented=!0},t}(),D=function(t){function n(s){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_(this,n);var r=T(this,t.call(this));if(!s||1!==s.nodeType)throw new TypeError("OdoPointer requires an element.");var a=Object.assign({},n.Defaults,o);r._shouldPreventDefault=a.preventEventDefault,r._el=s,r.pageStart=new i.Coordinate,r.page=new i.Coordinate,r.delta=new i.Coordinate,r._lastPosition=new i.Coordinate,r._friction=1,r.axis=a.axis,r.hasDragged=!1,r._isLocked=!1,r._isDeactivated=!1,r._enabled=!0,r._velocityTrackerId=null,r.startTime=0,r.deltaTime=0,r._lastTime=0,r.velocity=new i.Coordinate,r._hasTrackedVelocity=!1,r.dragEventTarget=document;var h=n.TouchActionSupport[r.axis];return r._isTouchActionSupported=!!h,r._shouldPreventDefault&&r._isTouchActionSupported?r.element.style[h]=n.TouchAction[r.axis]:r._shouldPreventDefault&&e.HAS_TOUCH_EVENTS&&window.addEventListener(i.events.TOUCHMOVE,i.utilities.noop),r.listen(),r}return f(n,t),n.prototype.listen=function(){this._onStart=this._handleDragStart.bind(this),e.HAS_POINTER_EVENTS?this._el.addEventListener(i.events.POINTERDOWN,this._onStart):(this._el.addEventListener(i.events.MOUSEDOWN,this._onStart),e.HAS_TOUCH_EVENTS&&this._el.addEventListener(i.events.TOUCHSTART,this._onStart)),this._el.addEventListener(i.events.DRAGSTART,n._preventDefault)},n.prototype.isXAxis=function(){return this.axis===n.Axis.X},n.prototype.isYAxis=function(){return this.axis===n.Axis.Y},n.prototype.isBothAxis=function(){return this.axis===n.Axis.BOTH},n.prototype.applyFriction=function(t){return t.scale(this.friction)},n.prototype._canStartDrag=function(t){return this.isEnabled&&(n.isTouchEvent(t)||0===t.button)},n.prototype._canContinueDrag=function(){return this.isEnabled&&!this._isDeactivated},n.prototype._handleDragStart=function(t){clearInterval(this._velocityTrackerId),this._canStartDrag(t)&&(this._setDragStartValues(n._getPageCoordinate(t)),this._emitEvent(this._createEvent(n.EventType.START,t))||(this._addDragHandlers(t.type),this._velocityTrackerId=setInterval(this._trackVelocity.bind(this),n.VELOCITY_INTERVAL)))},n.prototype._handleDragMove=function(t){this._canContinueDrag()&&(this._setDragMoveValues(n._getPageCoordinate(t)),this._emitEvent(this._createEvent(n.EventType.MOVE,t))||!this._shouldPreventDefault||this._isTouchActionSupported||this._finishDragMove(t))},n.prototype._finishDragMove=function(t){this._maybeLock(),this._maybeDeactivate(),this._isLocked&&t.preventDefault(),this._isDeactivated&&(clearInterval(this._velocityTrackerId),this.velocity.x=0,this.velocity.y=0)},n.prototype._handleDragEnd=function(t){clearInterval(this._velocityTrackerId),this.deltaTime=Date.now()-this.startTime,this._hasTrackedVelocity||this._trackVelocity(),this._removeDragHandlers();var e=this._createEvent(n.EventType.END,t);e.isCancelEvent=n._isCancelEvent(t),this._emitEvent(e)&&t.preventDefault(),this.hasDragged=!1,this._isDeactivated=!1,this._isLocked=!1},n.prototype._setDragStartValues=function(t){this.pageStart=t,this.page=t,this._lastPosition=t,this.delta=new i.Coordinate,this.velocity=new i.Coordinate,this._hasTrackedVelocity=!1,this.startTime=Date.now(),this._lastTime=Date.now(),this.deltaTime=0},n.prototype._setDragMoveValues=function(t){var e=i.Coordinate.difference(t,this.page);this.applyFriction(e),this.delta.translate(e),this.page=t,this.deltaTime=Date.now()-this.startTime,this.hasDragged=!0},n.prototype._maybeLock=function(){this._isLocked||(this._isLocked=this._shouldLock(this.delta))},n.prototype._maybeDeactivate=function(){this._isDeactivated||(this._isDeactivated=this._shouldDeactivate(this.delta))},n.prototype._shouldLock=function(t){var e=this.isXAxis()&&Math.abs(t.x)>n.LOCK_THRESHOLD,i=this.isYAxis()&&Math.abs(t.y)>n.LOCK_THRESHOLD;return this.isBothAxis()||e||i},n.prototype._shouldDeactivate=function(t){var e=this.isXAxis()&&Math.abs(t.y)>n.DRAG_THRESHOLD,i=this.isYAxis()&&Math.abs(t.x)>n.DRAG_THRESHOLD;return!this._isLocked&&(this.isBothAxis()||e||i)},n.prototype._createEvent=function(t,e){return new n.Event({type:t,pointerId:this.id,currentTarget:this.element,target:e.target,axis:this.axis,deltaTime:this.deltaTime,delta:this.delta,start:this.pageStart,end:this.page,currentVelocity:this.velocity})},n.prototype._addDragHandlers=function(t){var e=this.dragEventTarget;switch(this._onMove=this._handleDragMove.bind(this),this._onEnd=this._handleDragEnd.bind(this),t){case i.events.POINTERDOWN:e.addEventListener(i.events.POINTERMOVE,this._onMove),e.addEventListener(i.events.POINTERUP,this._onEnd),e.addEventListener(i.events.POINTERCANCEL,this._onEnd);break;case i.events.MOUSEDOWN:e.addEventListener(i.events.MOUSEMOVE,this._onMove),e.addEventListener(i.events.MOUSEUP,this._onEnd);break;case i.events.TOUCHSTART:e.addEventListener(i.events.TOUCHMOVE,this._onMove),e.addEventListener(i.events.TOUCHEND,this._onEnd),e.addEventListener(i.events.TOUCHCANCEL,this._onEnd)}},n.prototype._removeDragHandlers=function(){var t=this.dragEventTarget;t.removeEventListener(i.events.POINTERMOVE,this._onMove),t.removeEventListener(i.events.POINTERUP,this._onEnd),t.removeEventListener(i.events.POINTERCANCEL,this._onEnd),t.removeEventListener(i.events.MOUSEMOVE,this._onMove),t.removeEventListener(i.events.MOUSEUP,this._onEnd),t.removeEventListener(i.events.TOUCHMOVE,this._onMove),t.removeEventListener(i.events.TOUCHEND,this._onEnd),t.removeEventListener(i.events.TOUCHCANCEL,this._onEnd)},n.prototype._trackVelocity=function(){var t=Date.now(),e=t-this._lastTime,s=i.Coordinate.difference(this.page,this._lastPosition);this.applyFriction(s),this._lastTime=t,this._lastPosition=this.page;var o=n.MAX_VELOCITY;this.velocity.x=i.math.clamp(s.x/e,-o,o),this.velocity.y=i.math.clamp(s.y/e,-o,o),this._hasTrackedVelocity=!0},n.prototype.hasVelocity=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.SWIPE_VELOCITY;return this.isYAxis()?Math.abs(t.y)>e:this.isXAxis()?Math.abs(t.x)>e:Math.abs(t.x)>e||Math.abs(t.y)>e},n.prototype._emitEvent=function(t){return this.emit(t.type,t),t.defaultPrevented},n.prototype.dispose=function(){clearInterval(this._velocityTrackerId),this._removeDragHandlers(),this._el.removeEventListener(i.events.POINTERDOWN,this._onStart),this._el.removeEventListener(i.events.MOUSEDOWN,this._onStart),this._el.removeEventListener(i.events.TOUCHSTART,this._onStart),this._isTouchActionSupported?this._el.style[n.TouchActionSupport[this.axis]]="":this._shouldPreventDefault&&e.HAS_TOUCH_EVENTS&&window.removeEventListener(i.events.TOUCHMOVE,i.utilities.noop),this._el=null,this.dragEventTarget=null},n.isTouchEvent=function(t){return!!t.changedTouches},n._isCancelEvent=function(t){return t.type===i.events.POINTERCANCEL||t.type===i.events.TOUCHCANCEL},n._getPageCoordinate=function(t){var e=void 0;return e=n.isTouchEvent(t)?t.changedTouches[0]:t,new i.Coordinate(e.pageX,e.pageY)},n._preventDefault=function(t){t.preventDefault()},E(n,[{key:"element",get:function(){return this._el}},{key:"isEnabled",get:function(){return this._enabled},set:function(t){this._enabled=t}},{key:"friction",get:function(){return this._friction},set:function(t){this._friction=t}}]),n}(t);return Object.assign(D,p),D.Event=y,D});
//# sourceMappingURL=odo-pointer.min.js.map
{
"name": "@odopod/odo-pointer",
"description": "An abstraction for pointer, mouse, and touch events.",
"version": "1.0.1",
"version": "1.0.2",
"main": "dist/odo-pointer.js",

@@ -15,4 +15,4 @@ "odoModule": "src/pointer.js",

"dependencies": {
"@odopod/odo-device": "^1.0.1",
"@odopod/odo-helpers": "^1.0.1",
"@odopod/odo-device": "^1.0.2",
"@odopod/odo-helpers": "^1.0.2",
"tiny-emitter": "^2.0.1"

@@ -19,0 +19,0 @@ },

@@ -21,3 +21,3 @@ import { Coordinate } from '@odopod/odo-helpers';

function finiteOrZero(velocity) {
return isFinite(velocity) ? velocity : 0;
return Number.isFinite(velocity) ? velocity : 0;
}

@@ -37,3 +37,4 @@

finiteOrZero(deltaX / deltaTime),
finiteOrZero(deltaY / deltaTime));
finiteOrZero(deltaY / deltaTime),
);
}

@@ -59,8 +60,12 @@

if (Math.abs(coord1.x - coord2.x) >= Math.abs(coord1.y - coord2.y)) {
return getTheDirection(coord1.x, coord2.x, settings.Direction.LEFT,
settings.Direction.RIGHT, settings.Direction.NONE);
return getTheDirection(
coord1.x, coord2.x, settings.Direction.LEFT,
settings.Direction.RIGHT, settings.Direction.NONE,
);
}
return getTheDirection(coord1.y, coord2.y, settings.Direction.UP,
settings.Direction.DOWN, settings.Direction.NONE);
return getTheDirection(
coord1.y, coord2.y, settings.Direction.UP,
settings.Direction.DOWN, settings.Direction.NONE,
);
}

@@ -190,4 +195,6 @@

*/
this.didMoveOnAxis = didMoveOnAxis(options.axis, this.direction,
this.delta.x, this.delta.y);
this.didMoveOnAxis = didMoveOnAxis(
options.axis, this.direction,
this.delta.x, this.delta.y,
);

@@ -194,0 +201,0 @@ /**

@@ -311,4 +311,6 @@ /**

// Every interval, calculate the current velocity of the drag.
this._velocityTrackerId = setInterval(this._trackVelocity.bind(this),
Pointer.VELOCITY_INTERVAL);
this._velocityTrackerId = setInterval(
this._trackVelocity.bind(this),
Pointer.VELOCITY_INTERVAL,
);
}

@@ -654,3 +656,3 @@ }

if (Pointer.isTouchEvent(evt)) {
pagePoints = evt.changedTouches[0];
pagePoints = evt.changedTouches[0]; // eslint-disable-line prefer-destructuring
} else {

@@ -657,0 +659,0 @@ pagePoints = evt;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc