dom-autoscroller
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -1,1 +0,1 @@ | ||
[object Object] | ||
var autoScroll=function(){"use strict";function e(e){function t(e){return"string"==typeof e?document.querySelector(e):e}function a(){S=!0}function l(){S=!1,u(Y)}function c(t){if(!t)return null;if(X===t)return t;for(var n=0;n<e.length;n++)if(e[n]===t)return t;for(;t=t.parentNode;)for(var n=0;n<e.length;n++)if(e[n]===t)return t;return null}function d(){for(var t=null,n=0;n<e.length;n++)o(L,e[n])&&(t=e[n]);return t}function f(e){if(p.autoScroll()){var t=e.target,n=document.body;X&&!o(L,X)&&(X=null),t&&t.parentNode===n?X=d():(t=c(t),X=t?t:d()),x&&(u(T),T=r(s)),X&&(u(Y),Y=r(m))}}function s(){w(x)}function m(){X&&(w(X),u(Y),Y=r(m))}function w(e){var t=n(e),o=void 0,i=void 0;o=L.x<t.left+p.margin?Math.floor(Math.max(-1,(L.x-t.left)/p.margin-1)*p.maxSpeed):L.x>t.right-p.margin?Math.ceil(Math.min(1,(L.x-t.right)/p.margin+1)*p.maxSpeed):0,i=L.y<t.top+p.margin?Math.floor(Math.max(-1,(L.y-t.top)/p.margin-1)*p.maxSpeed):L.y>t.bottom-p.margin?Math.ceil(Math.min(1,(L.y-t.bottom)/p.margin+1)*p.maxSpeed):0,setTimeout(function(){i&&h(e,i),o&&g(e,o)})}function h(e,t){e===window?window.scrollTo(e.pageXOffset,e.pageYOffset+t):e.scrollTop+=t}function g(e,t){e===window?window.scrollTo(e.pageXOffset+t,e.pageYOffset):e.scrollLeft+=t}var v=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},p=this,y=4;this.margin=v.margin||-1,this.scrolling=!1,this.scrollWhenOutside=v.scrollWhenOutside||!1;var L={},E=i(L),S=!1;window.addEventListener("mousemove",E,!1),window.addEventListener("touchmove",E,!1),isNaN(v.maxSpeed)||(y=v.maxSpeed),"boolean"==typeof v.autoScroll?this.autoScroll=v.autoScroll?function(){return!0}:function(){return!1}:"undefined"==typeof v.autoScroll?this.autoScroll=function(){return!1}:"function"==typeof v.autoScroll&&(this.autoScroll=v.autoScroll),this.destroy=function(){window.removeEventListener("mousemove",E,!1),window.removeEventListener("touchmove",E,!1),window.removeEventListener("mousedown",a,!1),window.removeEventListener("touchstart",a,!1),window.removeEventListener("mouseup",l,!1),window.removeEventListener("touchend",l,!1),e=[]},this.add=function(n){n=t(n);for(var o=0;o<e.length;o++)if(e[o]===n)return this;return e.push(n),this},this.remove=function(n){n=t(n);for(var o=0;o<e.length;o++)if(n===e[o])return e.splice(o,1),this;return this};var x=null,T=void 0;!function(t){e=[],t.forEach(function(e){e===window?x=window:p.add(e)})}(e),Object.defineProperties(this,{down:{get:function(){return S}},maxSpeed:{get:function(){return y}}});var X=null,Y=void 0;window.addEventListener("mousedown",a,!1),window.addEventListener("touchstart",a,!1),window.addEventListener("mouseup",l,!1),window.addEventListener("touchend",l,!1),window.addEventListener("mousemove",f,!1),window.addEventListener("touchmove",f,!1)}function t(t,n){return new e(t,n)}function n(e){if(e===window)return{top:0,left:0,right:window.innerWidth,bottom:window.innerHeight,width:window.innerWidth,height:window.innerHeight};try{return e.getBoundingClientRect()}catch(t){throw new TypeError("Can't call getBoundingClientRect on "+e)}}function o(e,t,o){return o=o||n(t),e.y>o.top&&e.y<o.bottom&&e.x>o.left&&e.x<o.right}var i=function(e){return function(t){if(t=t||window.event,e.target=t.target||t.srcElement||t.originalTarget,e.element=this,e.type=t.type,t.targetTouches)e.x=t.targetTouches[0].clientX,e.y=t.targetTouches[0].clientY,e.pageX=t.pageX,e.pageY=t.pageY;else{if(null===t.pageX&&null!==t.clientX){var n=t.target&&t.target.ownerDocument||document,o=n.documentElement,i=n.body;e.pageX=t.clientX+(o&&o.scrollLeft||i&&i.scrollLeft||0)-(o&&o.clientLeft||i&&i.clientLeft||0),e.pageY=t.clientY+(o&&o.scrollTop||i&&i.scrollTop||0)-(o&&o.clientTop||i&&i.clientTop||0)}else e.pageX=t.pageX,e.pageY=t.pageY;e.x=t.clientX,e.y=t.clientY}}},r=function(){return requestAnimationFrame?requestAnimationFrame:function(e){return setTimeout(e)}}(),u=function(){return cancelAnimationFrame?cancelAnimationFrame:clearTimeout}();return t}(); |
{ | ||
"name": "dom-autoscroller", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Auto scroll dom elements", | ||
@@ -5,0 +5,0 @@ "main": "dist/bundle.js", |
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
92998