dom-autoscroller
Advanced tools
Comparing version 2.1.3 to 2.1.4
@@ -196,3 +196,5 @@ import createPointCB from 'create-point-cb'; | ||
if (current && !inside(point, current)) { | ||
current = null; | ||
if (!self.scrollWhenOutside) { | ||
current = null; | ||
} | ||
} | ||
@@ -202,14 +204,22 @@ | ||
//The special condition to improve speed. | ||
current = getElementUnderPoint(); | ||
target = getElementUnderPoint(); | ||
} else { | ||
target = getTarget(target); | ||
if (target) { | ||
if (!target) { | ||
target = getElementUnderPoint(); | ||
} | ||
/*if(target){ | ||
current = target; | ||
} else { | ||
}else{ | ||
//The target might have still been moved. | ||
current = getElementUnderPoint(); | ||
} | ||
}*/ | ||
} | ||
//current = target; | ||
if (target && target !== current) { | ||
current = target; | ||
} | ||
if (hasWindow) { | ||
@@ -216,0 +226,0 @@ cancelFrame(windowAnimationFrame); |
@@ -200,3 +200,5 @@ 'use strict'; | ||
if (current && !inside(point, current)) { | ||
current = null; | ||
if (!self.scrollWhenOutside) { | ||
current = null; | ||
} | ||
} | ||
@@ -206,14 +208,22 @@ | ||
//The special condition to improve speed. | ||
current = getElementUnderPoint(); | ||
target = getElementUnderPoint(); | ||
} else { | ||
target = getTarget(target); | ||
if (target) { | ||
if (!target) { | ||
target = getElementUnderPoint(); | ||
} | ||
/*if(target){ | ||
current = target; | ||
} else { | ||
}else{ | ||
//The target might have still been moved. | ||
current = getElementUnderPoint(); | ||
} | ||
}*/ | ||
} | ||
//current = target; | ||
if (target && target !== current) { | ||
current = target; | ||
} | ||
if (hasWindow) { | ||
@@ -220,0 +230,0 @@ cancelFrame(windowAnimationFrame); |
@@ -256,3 +256,5 @@ var autoScroll = (function () { | ||
if (current && !inside(point, current)) { | ||
current = null; | ||
if (!self.scrollWhenOutside) { | ||
current = null; | ||
} | ||
} | ||
@@ -262,14 +264,22 @@ | ||
//The special condition to improve speed. | ||
current = getElementUnderPoint(); | ||
target = getElementUnderPoint(); | ||
} else { | ||
target = getTarget(target); | ||
if (target) { | ||
if (!target) { | ||
target = getElementUnderPoint(); | ||
} | ||
/*if(target){ | ||
current = target; | ||
} else { | ||
}else{ | ||
//The target might have still been moved. | ||
current = getElementUnderPoint(); | ||
} | ||
}*/ | ||
} | ||
//current = target; | ||
if (target && target !== current) { | ||
current = target; | ||
} | ||
if (hasWindow) { | ||
@@ -276,0 +286,0 @@ cancelFrame(windowAnimationFrame); |
@@ -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(){x=!0}function l(){x=!1,u(b),u(X)}function c(){x=!1}function d(t){if(!t)return null;if(Y===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 f(){for(var t=null,n=0;n<e.length;n++)o(E,e[n])&&(t=e[n]);return t}function s(e){if(y.autoScroll()){var t=e.target,n=document.body;Y&&!o(E,Y)&&(Y=null),t&&t.parentNode===n?Y=f():(t=d(t),Y=t?t:f()),T&&(u(X),X=r(m)),Y&&(u(b),b=r(w))}}function m(){h(T),u(X),X=r(m)}function w(){Y&&(h(Y),u(b),b=r(w))}function h(e){var t=n(e),o=void 0,i=void 0;o=E.x<t.left+y.margin?Math.floor(Math.max(-1,(E.x-t.left)/y.margin-1)*y.maxSpeed):E.x>t.right-y.margin?Math.ceil(Math.min(1,(E.x-t.right)/y.margin+1)*y.maxSpeed):0,i=E.y<t.top+y.margin?Math.floor(Math.max(-1,(E.y-t.top)/y.margin-1)*y.maxSpeed):E.y>t.bottom-y.margin?Math.ceil(Math.min(1,(E.y-t.bottom)/y.margin+1)*y.maxSpeed):0,setTimeout(function(){i&&g(e,i),o&&v(e,o)})}function g(e,t){e===window?window.scrollTo(e.pageXOffset,e.pageYOffset+t):e.scrollTop+=t}function v(e,t){e===window?window.scrollTo(e.pageXOffset+t,e.pageYOffset):e.scrollLeft+=t}var p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},y=this,L=4;this.margin=p.margin||-1,this.scrolling=!1,this.scrollWhenOutside=p.scrollWhenOutside||!1;var E={},S=i(E),x=!1;window.addEventListener("mousemove",S,!1),window.addEventListener("touchmove",S,!1),isNaN(p.maxSpeed)||(L=p.maxSpeed),"boolean"==typeof p.autoScroll?this.autoScroll=p.autoScroll?function(){return!0}:function(){return!1}:"undefined"==typeof p.autoScroll?this.autoScroll=function(){return!1}:"function"==typeof p.autoScroll&&(this.autoScroll=p.autoScroll),this.destroy=function(){window.removeEventListener("mousemove",S,!1),window.removeEventListener("touchmove",S,!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 T=null,X=void 0;!function(t){e=[],t.forEach(function(e){e===window?T=window:y.add(e)})}(e),Object.defineProperties(this,{down:{get:function(){return x}},maxSpeed:{get:function(){return L}}});var Y=null,b=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",s,!1),window.addEventListener("touchmove",s,!1),window.addEventListener("mouseleave",c,!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}(); | ||
var autoScroll=function(){"use strict";function e(e){function t(e){return"string"==typeof e?document.querySelector(e):e}function a(){x=!0}function l(){x=!1,u(b),u(X)}function c(){x=!1}function d(t){if(!t)return null;if(Y===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(E,e[n])&&(t=e[n]);return t}function f(e){if(y.autoScroll()){var t=e.target,n=document.body;Y&&!o(E,Y)&&(y.scrollWhenOutside||(Y=null)),t&&t.parentNode===n?t=s():(t=d(t),t||(t=s())),t&&t!==Y&&(Y=t),T&&(u(X),X=r(m)),Y&&(u(b),b=r(w))}}function m(){h(T),u(X),X=r(m)}function w(){Y&&(h(Y),u(b),b=r(w))}function h(e){var t=n(e),o=void 0,i=void 0;o=E.x<t.left+y.margin?Math.floor(Math.max(-1,(E.x-t.left)/y.margin-1)*y.maxSpeed):E.x>t.right-y.margin?Math.ceil(Math.min(1,(E.x-t.right)/y.margin+1)*y.maxSpeed):0,i=E.y<t.top+y.margin?Math.floor(Math.max(-1,(E.y-t.top)/y.margin-1)*y.maxSpeed):E.y>t.bottom-y.margin?Math.ceil(Math.min(1,(E.y-t.bottom)/y.margin+1)*y.maxSpeed):0,setTimeout(function(){i&&g(e,i),o&&v(e,o)})}function g(e,t){e===window?window.scrollTo(e.pageXOffset,e.pageYOffset+t):e.scrollTop+=t}function v(e,t){e===window?window.scrollTo(e.pageXOffset+t,e.pageYOffset):e.scrollLeft+=t}var p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},y=this,L=4;this.margin=p.margin||-1,this.scrolling=!1,this.scrollWhenOutside=p.scrollWhenOutside||!1;var E={},S=i(E),x=!1;window.addEventListener("mousemove",S,!1),window.addEventListener("touchmove",S,!1),isNaN(p.maxSpeed)||(L=p.maxSpeed),"boolean"==typeof p.autoScroll?this.autoScroll=p.autoScroll?function(){return!0}:function(){return!1}:"undefined"==typeof p.autoScroll?this.autoScroll=function(){return!1}:"function"==typeof p.autoScroll&&(this.autoScroll=p.autoScroll),this.destroy=function(){window.removeEventListener("mousemove",S,!1),window.removeEventListener("touchmove",S,!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 T=null,X=void 0;!function(t){e=[],t.forEach(function(e){e===window?T=window:y.add(e)})}(e),Object.defineProperties(this,{down:{get:function(){return x}},maxSpeed:{get:function(){return L}}});var Y=null,b=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),window.addEventListener("mouseleave",c,!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.3", | ||
"version": "2.1.4", | ||
"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
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
97190
886