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