dom-autoscroller
Advanced tools
Comparing version 2.1.4 to 2.1.5
@@ -25,6 +25,7 @@ import createPointCB from 'create-point-cb'; | ||
var self = this; | ||
var maxSpeed = 4; | ||
var maxSpeed = 4, | ||
scrolling = false; | ||
this.margin = options.margin || -1; | ||
this.scrolling = false; | ||
//this.scrolling = false; | ||
this.scrollWhenOutside = options.scrollWhenOutside || false; | ||
@@ -64,2 +65,4 @@ | ||
window.removeEventListener('touchend', onUp, false); | ||
window.removeEventListener('scroll', setScroll, true); | ||
elements = []; | ||
@@ -122,2 +125,12 @@ }; | ||
} | ||
}, | ||
point: { | ||
get: function get() { | ||
return point; | ||
} | ||
}, | ||
scrolling: { | ||
get: function get() { | ||
return scrolling; | ||
} | ||
} | ||
@@ -140,2 +153,20 @@ }); | ||
window.addEventListener('scroll', setScroll, true); | ||
function setScroll(e) { | ||
for (var i = 0; i < elements.length; i++) { | ||
if (elements[i] === e.target) { | ||
scrolling = true; | ||
break; | ||
} | ||
} | ||
if (scrolling) { | ||
requestAnimationFrame(function () { | ||
return scrolling = false; | ||
}); | ||
} | ||
} | ||
function onDown() { | ||
@@ -214,11 +245,4 @@ down = true; | ||
} | ||
/*if(target){ | ||
current = target; | ||
}else{ | ||
//The target might have still been moved. | ||
current = getElementUnderPoint(); | ||
}*/ | ||
} | ||
//current = target; | ||
if (target && target !== current) { | ||
@@ -297,3 +321,2 @@ current = target; | ||
} else { | ||
//el.scrollTop = el.scrollTop + amount; | ||
el.scrollTop += amount; | ||
@@ -307,3 +330,2 @@ } | ||
} else { | ||
//el.scrollLeft = el.scrollLeft + amount; | ||
el.scrollLeft += amount; | ||
@@ -310,0 +332,0 @@ } |
@@ -29,6 +29,7 @@ 'use strict'; | ||
var self = this; | ||
var maxSpeed = 4; | ||
var maxSpeed = 4, | ||
scrolling = false; | ||
this.margin = options.margin || -1; | ||
this.scrolling = false; | ||
//this.scrolling = false; | ||
this.scrollWhenOutside = options.scrollWhenOutside || false; | ||
@@ -68,2 +69,4 @@ | ||
window.removeEventListener('touchend', onUp, false); | ||
window.removeEventListener('scroll', setScroll, true); | ||
elements = []; | ||
@@ -126,2 +129,12 @@ }; | ||
} | ||
}, | ||
point: { | ||
get: function get() { | ||
return point; | ||
} | ||
}, | ||
scrolling: { | ||
get: function get() { | ||
return scrolling; | ||
} | ||
} | ||
@@ -144,2 +157,20 @@ }); | ||
window.addEventListener('scroll', setScroll, true); | ||
function setScroll(e) { | ||
for (var i = 0; i < elements.length; i++) { | ||
if (elements[i] === e.target) { | ||
scrolling = true; | ||
break; | ||
} | ||
} | ||
if (scrolling) { | ||
requestAnimationFrame(function () { | ||
return scrolling = false; | ||
}); | ||
} | ||
} | ||
function onDown() { | ||
@@ -218,11 +249,4 @@ down = true; | ||
} | ||
/*if(target){ | ||
current = target; | ||
}else{ | ||
//The target might have still been moved. | ||
current = getElementUnderPoint(); | ||
}*/ | ||
} | ||
//current = target; | ||
if (target && target !== current) { | ||
@@ -301,3 +325,2 @@ current = target; | ||
} else { | ||
//el.scrollTop = el.scrollTop + amount; | ||
el.scrollTop += amount; | ||
@@ -311,3 +334,2 @@ } | ||
} else { | ||
//el.scrollLeft = el.scrollLeft + amount; | ||
el.scrollLeft += amount; | ||
@@ -314,0 +336,0 @@ } |
@@ -85,6 +85,7 @@ var autoScroll = (function () { | ||
var self = this; | ||
var maxSpeed = 4; | ||
var maxSpeed = 4, | ||
scrolling = false; | ||
this.margin = options.margin || -1; | ||
this.scrolling = false; | ||
//this.scrolling = false; | ||
this.scrollWhenOutside = options.scrollWhenOutside || false; | ||
@@ -124,2 +125,4 @@ | ||
window.removeEventListener('touchend', onUp, false); | ||
window.removeEventListener('scroll', setScroll, true); | ||
elements = []; | ||
@@ -182,2 +185,12 @@ }; | ||
} | ||
}, | ||
point: { | ||
get: function get() { | ||
return point; | ||
} | ||
}, | ||
scrolling: { | ||
get: function get() { | ||
return scrolling; | ||
} | ||
} | ||
@@ -200,2 +213,20 @@ }); | ||
window.addEventListener('scroll', setScroll, true); | ||
function setScroll(e) { | ||
for (var i = 0; i < elements.length; i++) { | ||
if (elements[i] === e.target) { | ||
scrolling = true; | ||
break; | ||
} | ||
} | ||
if (scrolling) { | ||
requestAnimationFrame(function () { | ||
return scrolling = false; | ||
}); | ||
} | ||
} | ||
function onDown() { | ||
@@ -274,11 +305,4 @@ down = true; | ||
} | ||
/*if(target){ | ||
current = target; | ||
}else{ | ||
//The target might have still been moved. | ||
current = getElementUnderPoint(); | ||
}*/ | ||
} | ||
//current = target; | ||
if (target && target !== current) { | ||
@@ -357,3 +381,2 @@ current = target; | ||
} else { | ||
//el.scrollTop = el.scrollTop + amount; | ||
el.scrollTop += amount; | ||
@@ -367,3 +390,2 @@ } | ||
} else { | ||
//el.scrollLeft = el.scrollLeft + amount; | ||
el.scrollLeft += amount; | ||
@@ -370,0 +392,0 @@ } |
@@ -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 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}(); | ||
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}(); |
{ | ||
"name": "dom-autoscroller", | ||
"version": "2.1.4", | ||
"version": "2.1.5", | ||
"description": "Auto scroll dom elements", | ||
@@ -5,0 +5,0 @@ "main": "dist/bundle.js", |
@@ -198,4 +198,10 @@ dom-autoscroller | ||
### scrolling = Boolean | ||
Is one of the elements scrolling? | ||
### point = Object | ||
**This reference no longer exists.** | ||
A reference to the [pointer](https://github.com/hollowdoor/pointer_point) object. | ||
@@ -202,0 +208,0 @@ |
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
100988
937
241