virtual-scroll-pointer
Advanced tools
Comparing version 2.2.2 to 2.2.3
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).virtualScrollPointer=t()}(this,function(){var e=0;function t(t){return"__private_"+e+++"_"+t}function n(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}function o(){}o.prototype={on:function(e,t,n){var o=this.e||(this.e={});return(o[e]||(o[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var o=this;function i(){o.off(e,i),t.apply(n,arguments)}return i._=t,this.on(e,i,n)},emit:function(e){for(var t=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),o=0,i=n.length;o<i;o++)n[o].fn.apply(n[o].ctx,t);return this},off:function(e,t){var n=this.e||(this.e={}),o=n[e],i=[];if(o&&t)for(var s=0,r=o.length;s<r;s++)o[s].fn!==t&&o[s].fn._!==t&&i.push(o[s]);return i.length?n[e]=i:delete n[e],this}};var i=o;i.TinyEmitter=o;var s,r="virtualscroll",h=t("options"),a=t("el"),l=t("emitter"),u=t("event"),c=t("touchStart"),d=t("bodyTouchAction"),v=t("isCurrentPointerEvent"),p=t("pointerClickPrevent"),f=t("pointerDownPos");return function(){function e(e){var t=this;Object.defineProperty(this,h,{writable:!0,value:void 0}),Object.defineProperty(this,a,{writable:!0,value:void 0}),Object.defineProperty(this,l,{writable:!0,value:void 0}),Object.defineProperty(this,u,{writable:!0,value:void 0}),Object.defineProperty(this,c,{writable:!0,value:void 0}),Object.defineProperty(this,d,{writable:!0,value:void 0}),Object.defineProperty(this,v,{writable:!0,value:void 0}),Object.defineProperty(this,p,{writable:!0,value:void 0}),Object.defineProperty(this,f,{writable:!0,value:void 0}),this._onWheel=function(e){var o=n(t,h)[h],i=n(t,u)[u];i.deltaX=e.wheelDeltaX||-1*e.deltaX,i.deltaY=e.wheelDeltaY||-1*e.deltaY,s.isFirefox&&1===e.deltaMode&&(i.deltaX*=o.firefoxMultiplier,i.deltaY*=o.firefoxMultiplier),i.deltaX*=o.mouseMultiplier,i.deltaY*=o.mouseMultiplier,t._notify(e)},this._onMouseWheel=function(e){var o=n(t,u)[u];o.deltaX=e.wheelDeltaX?e.wheelDeltaX:0,o.deltaY=e.wheelDeltaY?e.wheelDeltaY:e.wheelDelta,t._notify(e)},this._onTouchStart=function(e){var o=e.targetTouches?e.targetTouches[0]:e;if(n(t,c)[c].x=o.pageX,n(t,c)[c].y=o.pageY,"pointerdown"===e.type){n(t,v)[v]=!0,n(t,f)[f]={x:o.pageX,y:o.pageY},document.body.addEventListener("pointermove",t._onTouchMove);var i=function e(o){console.log(o.type),document.body.removeEventListener("pointermove",t._onTouchMove),document.body.removeEventListener("pointerup",e),document.body.removeEventListener("pointerleave",e),n(t,f)[f]=null,n(t,v)[v]=!1,n(t,p)[p]&&setTimeout(function(){n(t,a)[a].removeEventListener("click",n(t,p)[p],{capture:!0}),n(t,p)[p]=null})};document.body.addEventListener("pointerup",i),document.body.addEventListener("pointerleave",i)}},this._onTouchMove=function(e){var o=n(t,h)[h];o.preventTouch&&!e.target.classList.contains(o.unpreventTouchClass)&&e.preventDefault();var i=n(t,u)[u],s=e.targetTouches?e.targetTouches[0]:e;i.deltaX=(s.pageX-n(t,c)[c].x)*o.touchMultiplier,i.deltaY=(s.pageY-n(t,c)[c].y)*o.touchMultiplier,n(t,v)[v]&&(e.preventDefault(),n(t,p)[p]||Math.sqrt(Math.pow((s.pageX-n(t,f)[f].x)/o.touchMultiplier,2),Math.pow((s.pageY-n(t,f)[f].y)/o.touchMultiplier,2))>n(t,h)[h].pointerClickDelta&&(n(t,p)[p]=function(e){e.preventDefault(),e.stopPropagation()},n(t,a)[a].addEventListener("click",n(t,p)[p],{capture:!0}))),n(t,c)[c].x=s.pageX,n(t,c)[c].y=s.pageY,t._notify(e)},this._onKeyDown=function(e){var o=n(t,u)[u];o.deltaX=o.deltaY=0;var i=window.innerHeight-40;switch(e.keyCode){case 37:case 38:o.deltaY=n(t,h)[h].keyStep;break;case 39:case 40:o.deltaY=-n(t,h)[h].keyStep;break;case 32:o.deltaY=i*(e.shiftKey?1:-1);break;default:return}t._notify(e)},n(this,a)[a]=window,n(this,v)[v]=!1,n(this,p)[p]=null,n(this,f)[f]=null,e&&e.el&&(n(this,a)[a]=e.el,delete e.el),s||(s={hasWheelEvent:"onwheel"in document,hasMouseWheelEvent:"onmousewheel"in document,hasTouch:"ontouchstart"in document,hasTouchWin:navigator.msMaxTouchPoints&&navigator.msMaxTouchPoints>1,hasPointer:!!window.navigator.msPointerEnabled,hasKeyDown:"onkeydown"in document,isFirefox:navigator.userAgent.indexOf("Firefox")>-1}),n(this,h)[h]=Object.assign({mouseMultiplier:1,touchMultiplier:2,firefoxMultiplier:15,keyStep:120,preventTouch:!1,unpreventTouchClass:"vs-touchmove-allowed",useKeyboard:!0,useTouch:!0,usePointer:!0,pointerClickDelta:1*window.devicePixelRatio},e),n(this,l)[l]=new i,n(this,u)[u]={y:0,x:0,deltaX:0,deltaY:0},n(this,c)[c]={x:null,y:null},n(this,d)[d]=null,void 0!==n(this,h)[h].passive&&(this.listenerOptions={passive:n(this,h)[h].passive})}var t=e.prototype;return t._notify=function(e){var t=n(this,u)[u];t.x+=t.deltaX,t.y+=t.deltaY,n(this,l)[l].emit(r,{x:t.x,y:t.y,deltaX:t.deltaX,deltaY:t.deltaY,originalEvent:e})},t._bind=function(){s.hasWheelEvent&&n(this,a)[a].addEventListener("wheel",this._onWheel,this.listenerOptions),s.hasMouseWheelEvent&&n(this,a)[a].addEventListener("mousewheel",this._onMouseWheel,this.listenerOptions),s.hasTouch&&n(this,h)[h].useTouch&&(n(this,a)[a].addEventListener("touchstart",this._onTouchStart,this.listenerOptions),n(this,a)[a].addEventListener("touchmove",this._onTouchMove,this.listenerOptions)),!s.hasTouch&&n(this,h)[h].usePointer&&n(this,a)[a].addEventListener("pointerdown",this._onTouchStart),s.hasPointer&&s.hasTouchWin&&(n(this,d)[d]=document.body.style.msTouchAction,document.body.style.msTouchAction="none",n(this,a)[a].addEventListener("MSPointerDown",this._onTouchStart,!0),n(this,a)[a].addEventListener("MSPointerMove",this._onTouchMove,!0)),s.hasKeyDown&&n(this,h)[h].useKeyboard&&document.addEventListener("keydown",this._onKeyDown)},t._unbind=function(){s.hasWheelEvent&&n(this,a)[a].removeEventListener("wheel",this._onWheel),s.hasMouseWheelEvent&&n(this,a)[a].removeEventListener("mousewheel",this._onMouseWheel),s.hasTouch&&(n(this,a)[a].removeEventListener("touchstart",this._onTouchStart),n(this,a)[a].removeEventListener("touchmove",this._onTouchMove)),!s.hasTouch&&n(this,h)[h].usePointer&&n(this,a)[a].removeEventListener("pointerdown",this._onTouchStart),s.hasPointer&&s.hasTouchWin&&(document.body.style.msTouchAction=n(this,d)[d],n(this,a)[a].removeEventListener("MSPointerDown",this._onTouchStart,!0),n(this,a)[a].removeEventListener("MSPointerMove",this._onTouchMove,!0)),s.hasKeyDown&&n(this,h)[h].useKeyboard&&document.removeEventListener("keydown",this._onKeyDown)},t.on=function(e,t){n(this,l)[l].on(r,e,t);var o=n(this,l)[l].e;o&&o[r]&&1===o[r].length&&this._bind()},t.off=function(e,t){n(this,l)[l].off(r,e,t);var o=n(this,l)[l].e;(!o[r]||o[r].length<=0)&&this._unbind()},t.destroy=function(){n(this,l)[l].off(),this._unbind()},e}()}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).virtualScrollPointer=t()}(this,function(){var e=0;function t(t){return"__private_"+e+++"_"+t}function n(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}function i(){}i.prototype={on:function(e,t,n){var i=this.e||(this.e={});return(i[e]||(i[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var i=this;function o(){i.off(e,o),t.apply(n,arguments)}return o._=t,this.on(e,o,n)},emit:function(e){for(var t=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),i=0,o=n.length;i<o;i++)n[i].fn.apply(n[i].ctx,t);return this},off:function(e,t){var n=this.e||(this.e={}),i=n[e],o=[];if(i&&t)for(var s=0,r=i.length;s<r;s++)i[s].fn!==t&&i[s].fn._!==t&&o.push(i[s]);return o.length?n[e]=o:delete n[e],this}};var o=i;o.TinyEmitter=i;var s,r="virtualscroll",h=t("options"),a=t("el"),l=t("emitter"),u=t("event"),c=t("touchStart"),d=t("bodyTouchAction"),v=t("isCurrentPointerEvent"),p=t("pointerClickPrevent"),f=t("pointerDownPos");return function(){function e(e){var t=this;Object.defineProperty(this,h,{writable:!0,value:void 0}),Object.defineProperty(this,a,{writable:!0,value:void 0}),Object.defineProperty(this,l,{writable:!0,value:void 0}),Object.defineProperty(this,u,{writable:!0,value:void 0}),Object.defineProperty(this,c,{writable:!0,value:void 0}),Object.defineProperty(this,d,{writable:!0,value:void 0}),Object.defineProperty(this,v,{writable:!0,value:void 0}),Object.defineProperty(this,p,{writable:!0,value:void 0}),Object.defineProperty(this,f,{writable:!0,value:void 0}),this._onWheel=function(e){var i=n(t,h)[h],o=n(t,u)[u];o.deltaX=e.wheelDeltaX||-1*e.deltaX,o.deltaY=e.wheelDeltaY||-1*e.deltaY,s.isFirefox&&1===e.deltaMode&&(o.deltaX*=i.firefoxMultiplier,o.deltaY*=i.firefoxMultiplier),o.deltaX*=i.mouseMultiplier,o.deltaY*=i.mouseMultiplier,t._notify(e)},this._onMouseWheel=function(e){var i=n(t,u)[u];i.deltaX=e.wheelDeltaX?e.wheelDeltaX:0,i.deltaY=e.wheelDeltaY?e.wheelDeltaY:e.wheelDelta,t._notify(e)},this._onTouchStart=function(e){var i=e.targetTouches?e.targetTouches[0]:e;if(n(t,c)[c].x=i.pageX,n(t,c)[c].y=i.pageY,"pointerdown"===e.type){n(t,v)[v]=!0,n(t,f)[f]={x:i.pageX,y:i.pageY},document.body.addEventListener("pointermove",t._onTouchMove);var o=function e(i){document.body.removeEventListener("pointermove",t._onTouchMove),document.body.removeEventListener("pointerup",e),document.body.removeEventListener("pointerleave",e),n(t,f)[f]=null,n(t,v)[v]=!1,n(t,p)[p]&&setTimeout(function(){n(t,a)[a].removeEventListener("click",n(t,p)[p],{capture:!0}),n(t,p)[p]=null})};document.body.addEventListener("pointerup",o),document.body.addEventListener("pointerleave",o)}},this._onTouchMove=function(e){var i=n(t,h)[h];i.preventTouch&&!e.target.classList.contains(i.unpreventTouchClass)&&e.preventDefault();var o=n(t,u)[u],s=e.targetTouches?e.targetTouches[0]:e;o.deltaX=(s.pageX-n(t,c)[c].x)*i.touchMultiplier,o.deltaY=(s.pageY-n(t,c)[c].y)*i.touchMultiplier,n(t,v)[v]&&(e.preventDefault(),n(t,p)[p]||Math.sqrt(Math.pow((s.pageX-n(t,f)[f].x)/i.touchMultiplier,2),Math.pow((s.pageY-n(t,f)[f].y)/i.touchMultiplier,2))>n(t,h)[h].pointerClickDelta&&(n(t,p)[p]=function(e){e.preventDefault(),e.stopPropagation()},n(t,a)[a].addEventListener("click",n(t,p)[p],{capture:!0}))),n(t,c)[c].x=s.pageX,n(t,c)[c].y=s.pageY,t._notify(e)},this._onKeyDown=function(e){var i=n(t,u)[u];i.deltaX=i.deltaY=0;var o=window.innerHeight-40;switch(e.keyCode){case 37:case 38:i.deltaY=n(t,h)[h].keyStep;break;case 39:case 40:i.deltaY=-n(t,h)[h].keyStep;break;case 32:i.deltaY=o*(e.shiftKey?1:-1);break;default:return}t._notify(e)},n(this,a)[a]=window,n(this,v)[v]=!1,n(this,p)[p]=null,n(this,f)[f]=null,e&&e.el&&(n(this,a)[a]=e.el,delete e.el),s||(s={hasWheelEvent:"onwheel"in document,hasMouseWheelEvent:"onmousewheel"in document,hasTouch:"ontouchstart"in document,hasTouchWin:navigator.msMaxTouchPoints&&navigator.msMaxTouchPoints>1,hasPointer:!!window.navigator.msPointerEnabled,hasKeyDown:"onkeydown"in document,isFirefox:navigator.userAgent.indexOf("Firefox")>-1}),n(this,h)[h]=Object.assign({mouseMultiplier:1,touchMultiplier:2,firefoxMultiplier:15,keyStep:120,preventTouch:!1,unpreventTouchClass:"vs-touchmove-allowed",useKeyboard:!0,useTouch:!0,usePointer:!0,pointerClickDelta:1*window.devicePixelRatio},e),n(this,l)[l]=new o,n(this,u)[u]={y:0,x:0,deltaX:0,deltaY:0},n(this,c)[c]={x:null,y:null},n(this,d)[d]=null,void 0!==n(this,h)[h].passive&&(this.listenerOptions={passive:n(this,h)[h].passive})}var t=e.prototype;return t._notify=function(e){var t=n(this,u)[u];t.x+=t.deltaX,t.y+=t.deltaY,n(this,l)[l].emit(r,{x:t.x,y:t.y,deltaX:t.deltaX,deltaY:t.deltaY,originalEvent:e})},t._bind=function(){s.hasWheelEvent&&n(this,a)[a].addEventListener("wheel",this._onWheel,this.listenerOptions),s.hasMouseWheelEvent&&n(this,a)[a].addEventListener("mousewheel",this._onMouseWheel,this.listenerOptions),s.hasTouch&&n(this,h)[h].useTouch&&(n(this,a)[a].addEventListener("touchstart",this._onTouchStart,this.listenerOptions),n(this,a)[a].addEventListener("touchmove",this._onTouchMove,this.listenerOptions)),!s.hasTouch&&n(this,h)[h].usePointer&&n(this,a)[a].addEventListener("pointerdown",this._onTouchStart),s.hasPointer&&s.hasTouchWin&&(n(this,d)[d]=document.body.style.msTouchAction,document.body.style.msTouchAction="none",n(this,a)[a].addEventListener("MSPointerDown",this._onTouchStart,!0),n(this,a)[a].addEventListener("MSPointerMove",this._onTouchMove,!0)),s.hasKeyDown&&n(this,h)[h].useKeyboard&&document.addEventListener("keydown",this._onKeyDown)},t._unbind=function(){s.hasWheelEvent&&n(this,a)[a].removeEventListener("wheel",this._onWheel),s.hasMouseWheelEvent&&n(this,a)[a].removeEventListener("mousewheel",this._onMouseWheel),s.hasTouch&&(n(this,a)[a].removeEventListener("touchstart",this._onTouchStart),n(this,a)[a].removeEventListener("touchmove",this._onTouchMove)),!s.hasTouch&&n(this,h)[h].usePointer&&n(this,a)[a].removeEventListener("pointerdown",this._onTouchStart),s.hasPointer&&s.hasTouchWin&&(document.body.style.msTouchAction=n(this,d)[d],n(this,a)[a].removeEventListener("MSPointerDown",this._onTouchStart,!0),n(this,a)[a].removeEventListener("MSPointerMove",this._onTouchMove,!0)),s.hasKeyDown&&n(this,h)[h].useKeyboard&&document.removeEventListener("keydown",this._onKeyDown)},t.on=function(e,t){n(this,l)[l].on(r,e,t);var i=n(this,l)[l].e;i&&i[r]&&1===i[r].length&&this._bind()},t.off=function(e,t){n(this,l)[l].off(r,e,t);var i=n(this,l)[l].e;(!i[r]||i[r].length<=0)&&this._unbind()},t.destroy=function(){n(this,l)[l].off(),this._unbind()},e}()}); |
{ | ||
"name": "virtual-scroll-pointer", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"description": "Enhanced Custom scroll events for smooth, fake scroll, with mouse pointer support.", | ||
@@ -5,0 +5,0 @@ "main": "lib/virtualscroll.js", |
@@ -123,3 +123,2 @@ import Emitter from "tiny-emitter"; | ||
const onPointerUp = (e) => { | ||
console.log(e.type); | ||
document.body.removeEventListener("pointermove", this._onTouchMove); | ||
@@ -126,0 +125,0 @@ document.body.removeEventListener("pointerup", onPointerUp); |
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
25577
430