dom-autoscroller
Advanced tools
Comparing version 2.1.5 to 2.1.6
@@ -102,2 +102,6 @@ import createPointCB from 'create-point-cb'; | ||
if (Object.prototype.toString.call(elements) !== '[object Array]') { | ||
elements = [elements]; | ||
} | ||
(function (temp) { | ||
@@ -104,0 +108,0 @@ elements = []; |
@@ -106,2 +106,6 @@ 'use strict'; | ||
if (Object.prototype.toString.call(elements) !== '[object Array]') { | ||
elements = [elements]; | ||
} | ||
(function (temp) { | ||
@@ -108,0 +112,0 @@ elements = []; |
@@ -162,2 +162,6 @@ var autoScroll = (function () { | ||
if (Object.prototype.toString.call(elements) !== '[object Array]') { | ||
elements = [elements]; | ||
} | ||
(function (temp) { | ||
@@ -164,0 +168,0 @@ elements = []; |
@@ -1,1 +0,1 @@ | ||
var autoScroll=function(){"use strict";function e(e){function t(e){return"string"==typeof e?document.querySelector(e):e}function a(t){for(var n=0;n<e.length;n++)if(e[n]===t.target){S=!0;break}S&&requestAnimationFrame(function(){return S=!1})}function l(){X=!0}function c(){X=!1,u(O),u(b)}function d(){X=!1}function f(t){if(!t)return null;if(M===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 s(){for(var t=null,n=0;n<e.length;n++)o(x,e[n])&&(t=e[n]);return t}function m(e){if(E.autoScroll()){var t=e.target,n=document.body;M&&!o(x,M)&&(E.scrollWhenOutside||(M=null)),t&&t.parentNode===n?t=s():(t=f(t),t||(t=s())),t&&t!==M&&(M=t),Y&&(u(b),b=i(w)),M&&(u(O),O=i(g))}}function w(){h(Y),u(b),b=i(w)}function g(){M&&(h(M),u(O),O=i(g))}function h(e){var t=n(e),o=void 0,r=void 0;o=x.x<t.left+E.margin?Math.floor(Math.max(-1,(x.x-t.left)/E.margin-1)*E.maxSpeed):x.x>t.right-E.margin?Math.ceil(Math.min(1,(x.x-t.right)/E.margin+1)*E.maxSpeed):0,r=x.y<t.top+E.margin?Math.floor(Math.max(-1,(x.y-t.top)/E.margin-1)*E.maxSpeed):x.y>t.bottom-E.margin?Math.ceil(Math.min(1,(x.y-t.bottom)/E.margin+1)*E.maxSpeed):0,setTimeout(function(){r&&v(e,r),o&&p(e,o)})}function v(e,t){e===window?window.scrollTo(e.pageXOffset,e.pageYOffset+t):e.scrollTop+=t}function p(e,t){e===window?window.scrollTo(e.pageXOffset+t,e.pageYOffset):e.scrollLeft+=t}var L=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},E=this,y=4,S=!1;this.margin=L.margin||-1,this.scrollWhenOutside=L.scrollWhenOutside||!1;var x={},T=r(x),X=!1;window.addEventListener("mousemove",T,!1),window.addEventListener("touchmove",T,!1),isNaN(L.maxSpeed)||(y=L.maxSpeed),"boolean"==typeof L.autoScroll?this.autoScroll=L.autoScroll?function(){return!0}:function(){return!1}:"undefined"==typeof L.autoScroll?this.autoScroll=function(){return!1}:"function"==typeof L.autoScroll&&(this.autoScroll=L.autoScroll),this.destroy=function(){window.removeEventListener("mousemove",T,!1),window.removeEventListener("touchmove",T,!1),window.removeEventListener("mousedown",l,!1),window.removeEventListener("touchstart",l,!1),window.removeEventListener("mouseup",c,!1),window.removeEventListener("touchend",c,!1),window.removeEventListener("scroll",a,!0),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 Y=null,b=void 0;!function(t){e=[],t.forEach(function(e){e===window?Y=window:E.add(e)})}(e),Object.defineProperties(this,{down:{get:function(){return X}},maxSpeed:{get:function(){return y}},point:{get:function(){return x}},scrolling:{get:function(){return S}}});var M=null,O=void 0;window.addEventListener("mousedown",l,!1),window.addEventListener("touchstart",l,!1),window.addEventListener("mouseup",c,!1),window.addEventListener("touchend",c,!1),window.addEventListener("mousemove",m,!1),window.addEventListener("touchmove",m,!1),window.addEventListener("mouseleave",d,!1),window.addEventListener("scroll",a,!0)}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 r=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,r=n.body;e.pageX=t.clientX+(o&&o.scrollLeft||r&&r.scrollLeft||0)-(o&&o.clientLeft||r&&r.clientLeft||0),e.pageY=t.clientY+(o&&o.scrollTop||r&&r.scrollTop||0)-(o&&o.clientTop||r&&r.clientTop||0)}else e.pageX=t.pageX,e.pageY=t.pageY;e.x=t.clientX,e.y=t.clientY}}},i=function(){return requestAnimationFrame?requestAnimationFrame:function(e){return setTimeout(e)}}(),u=function(){return cancelAnimationFrame?cancelAnimationFrame:clearTimeout}();return t}(); | ||
var autoScroll=function(){"use strict";function e(e){function t(e){return"string"==typeof e?document.querySelector(e):e}function a(t){for(var n=0;n<e.length;n++)if(e[n]===t.target){S=!0;break}S&&requestAnimationFrame(function(){return S=!1})}function c(){X=!0}function l(){X=!1,u(M),u(Y)}function d(){X=!1}function f(t){if(!t)return null;if(O===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 s(){for(var t=null,n=0;n<e.length;n++)o(x,e[n])&&(t=e[n]);return t}function m(e){if(L.autoScroll()){var t=e.target,n=document.body;O&&!o(x,O)&&(L.scrollWhenOutside||(O=null)),t&&t.parentNode===n?t=s():(t=f(t),t||(t=s())),t&&t!==O&&(O=t),b&&(u(Y),Y=i(w)),O&&(u(M),M=i(g))}}function w(){h(b),u(Y),Y=i(w)}function g(){O&&(h(O),u(M),M=i(g))}function h(e){var t=n(e),o=void 0,r=void 0;o=x.x<t.left+L.margin?Math.floor(Math.max(-1,(x.x-t.left)/L.margin-1)*L.maxSpeed):x.x>t.right-L.margin?Math.ceil(Math.min(1,(x.x-t.right)/L.margin+1)*L.maxSpeed):0,r=x.y<t.top+L.margin?Math.floor(Math.max(-1,(x.y-t.top)/L.margin-1)*L.maxSpeed):x.y>t.bottom-L.margin?Math.ceil(Math.min(1,(x.y-t.bottom)/L.margin+1)*L.maxSpeed):0,setTimeout(function(){r&&v(e,r),o&&p(e,o)})}function v(e,t){e===window?window.scrollTo(e.pageXOffset,e.pageYOffset+t):e.scrollTop+=t}function p(e,t){e===window?window.scrollTo(e.pageXOffset+t,e.pageYOffset):e.scrollLeft+=t}var y=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},L=this,E=4,S=!1;this.margin=y.margin||-1,this.scrollWhenOutside=y.scrollWhenOutside||!1;var x={},T=r(x),X=!1;window.addEventListener("mousemove",T,!1),window.addEventListener("touchmove",T,!1),isNaN(y.maxSpeed)||(E=y.maxSpeed),"boolean"==typeof y.autoScroll?this.autoScroll=y.autoScroll?function(){return!0}:function(){return!1}:"undefined"==typeof y.autoScroll?this.autoScroll=function(){return!1}:"function"==typeof y.autoScroll&&(this.autoScroll=y.autoScroll),this.destroy=function(){window.removeEventListener("mousemove",T,!1),window.removeEventListener("touchmove",T,!1),window.removeEventListener("mousedown",c,!1),window.removeEventListener("touchstart",c,!1),window.removeEventListener("mouseup",l,!1),window.removeEventListener("touchend",l,!1),window.removeEventListener("scroll",a,!0),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 b=null,Y=void 0;"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),function(t){e=[],t.forEach(function(e){e===window?b=window:L.add(e)})}(e),Object.defineProperties(this,{down:{get:function(){return X}},maxSpeed:{get:function(){return E}},point:{get:function(){return x}},scrolling:{get:function(){return S}}});var O=null,M=void 0;window.addEventListener("mousedown",c,!1),window.addEventListener("touchstart",c,!1),window.addEventListener("mouseup",l,!1),window.addEventListener("touchend",l,!1),window.addEventListener("mousemove",m,!1),window.addEventListener("touchmove",m,!1),window.addEventListener("mouseleave",d,!1),window.addEventListener("scroll",a,!0)}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 r=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,r=n.body;e.pageX=t.clientX+(o&&o.scrollLeft||r&&r.scrollLeft||0)-(o&&o.clientLeft||r&&r.clientLeft||0),e.pageY=t.clientY+(o&&o.scrollTop||r&&r.scrollTop||0)-(o&&o.clientTop||r&&r.clientTop||0)}else e.pageX=t.pageX,e.pageY=t.pageY;e.x=t.clientX,e.y=t.clientY}}},i=function(){return requestAnimationFrame?requestAnimationFrame:function(e){return setTimeout(e)}}(),u=function(){return cancelAnimationFrame?cancelAnimationFrame:clearTimeout}();return t}(); |
{ | ||
"name": "dom-autoscroller", | ||
"version": "2.1.5", | ||
"version": "2.1.6", | ||
"description": "Auto scroll dom elements", | ||
@@ -5,0 +5,0 @@ "main": "dist/bundle.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
102184
946