Socket
Socket
Sign inDemoInstall

@mattlewis92/dom-autoscroller

Package Overview
Dependencies
8
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.3.4 to 2.3.5

63

dist/bundle.es.js

@@ -6,2 +6,43 @@ import { boolean } from 'type-func';

var prefix = [ 'webkit', 'moz', 'ms', 'o' ];
var window = typeof window !== "undefined" ? window : {};
var requestFrame = (function () {
for ( var i = 0, limit = prefix.length ; i < limit && ! window.requestAnimationFrame ; ++i ) {
window.requestAnimationFrame = window[ prefix[ i ] + 'RequestAnimationFrame' ];
}
if ( ! window.requestAnimationFrame ) {
var lastTime = 0;
window.requestAnimationFrame = function (callback) {
var now = new Date().getTime();
var ttc = Math.max( 0, 16 - now - lastTime );
var timer = window.setTimeout( function () { return callback( now + ttc ); }, ttc );
lastTime = now + ttc;
return timer;
};
}
return window.requestAnimationFrame.bind( window );
})();
var cancelFrame = (function () {
for ( var i = 0, limit = prefix.length ; i < limit && ! window.cancelAnimationFrame ; ++i ) {
window.cancelAnimationFrame = window[ prefix[ i ] + 'CancelAnimationFrame' ] || window[ prefix[ i ] + 'CancelRequestAnimationFrame' ];
}
if ( ! window.cancelAnimationFrame ) {
window.cancelAnimationFrame = function (timer) {
window.clearTimeout( timer );
};
}
return window.cancelAnimationFrame.bind( window );
})();
function AutoScroller(elements, options){

@@ -131,3 +172,3 @@ if ( options === void 0 ) options = {};

if(scrolling){
requestAnimationFrame(function (){ return scrolling = false; });
requestFrame(function (){ return scrolling = false; });
}

@@ -145,4 +186,4 @@ }

function cleanAnimation(){
cancelAnimationFrame(animationFrame);
cancelAnimationFrame(windowAnimationFrame);
cancelFrame(animationFrame);
cancelFrame(windowAnimationFrame);
}

@@ -219,4 +260,4 @@ function onMouseOut(){

if(hasWindow){
cancelAnimationFrame(windowAnimationFrame);
windowAnimationFrame = requestAnimationFrame(scrollWindow);
cancelFrame(windowAnimationFrame);
windowAnimationFrame = requestFrame(scrollWindow);
}

@@ -229,4 +270,4 @@

cancelAnimationFrame(animationFrame);
animationFrame = requestAnimationFrame(scrollTick);
cancelFrame(animationFrame);
animationFrame = requestFrame(scrollTick);
}

@@ -237,4 +278,4 @@

cancelAnimationFrame(windowAnimationFrame);
windowAnimationFrame = requestAnimationFrame(scrollWindow);
cancelFrame(windowAnimationFrame);
windowAnimationFrame = requestFrame(scrollWindow);
}

@@ -250,4 +291,4 @@

cancelAnimationFrame(animationFrame);
animationFrame = requestAnimationFrame(scrollTick);
cancelFrame(animationFrame);
animationFrame = requestFrame(scrollTick);

@@ -254,0 +295,0 @@ }

@@ -10,2 +10,43 @@ 'use strict';

var prefix = [ 'webkit', 'moz', 'ms', 'o' ];
var window = typeof window !== "undefined" ? window : {};
var requestFrame = (function () {
for ( var i = 0, limit = prefix.length ; i < limit && ! window.requestAnimationFrame ; ++i ) {
window.requestAnimationFrame = window[ prefix[ i ] + 'RequestAnimationFrame' ];
}
if ( ! window.requestAnimationFrame ) {
var lastTime = 0;
window.requestAnimationFrame = function (callback) {
var now = new Date().getTime();
var ttc = Math.max( 0, 16 - now - lastTime );
var timer = window.setTimeout( function () { return callback( now + ttc ); }, ttc );
lastTime = now + ttc;
return timer;
};
}
return window.requestAnimationFrame.bind( window );
})();
var cancelFrame = (function () {
for ( var i = 0, limit = prefix.length ; i < limit && ! window.cancelAnimationFrame ; ++i ) {
window.cancelAnimationFrame = window[ prefix[ i ] + 'CancelAnimationFrame' ] || window[ prefix[ i ] + 'CancelRequestAnimationFrame' ];
}
if ( ! window.cancelAnimationFrame ) {
window.cancelAnimationFrame = function (timer) {
window.clearTimeout( timer );
};
}
return window.cancelAnimationFrame.bind( window );
})();
function AutoScroller(elements, options){

@@ -135,3 +176,3 @@ if ( options === void 0 ) options = {};

if(scrolling){
requestAnimationFrame(function (){ return scrolling = false; });
requestFrame(function (){ return scrolling = false; });
}

@@ -149,4 +190,4 @@ }

function cleanAnimation(){
cancelAnimationFrame(animationFrame);
cancelAnimationFrame(windowAnimationFrame);
cancelFrame(animationFrame);
cancelFrame(windowAnimationFrame);
}

@@ -223,4 +264,4 @@ function onMouseOut(){

if(hasWindow){
cancelAnimationFrame(windowAnimationFrame);
windowAnimationFrame = requestAnimationFrame(scrollWindow);
cancelFrame(windowAnimationFrame);
windowAnimationFrame = requestFrame(scrollWindow);
}

@@ -233,4 +274,4 @@

cancelAnimationFrame(animationFrame);
animationFrame = requestAnimationFrame(scrollTick);
cancelFrame(animationFrame);
animationFrame = requestFrame(scrollTick);
}

@@ -241,4 +282,4 @@

cancelAnimationFrame(windowAnimationFrame);
windowAnimationFrame = requestAnimationFrame(scrollWindow);
cancelFrame(windowAnimationFrame);
windowAnimationFrame = requestFrame(scrollWindow);
}

@@ -254,4 +295,4 @@

cancelAnimationFrame(animationFrame);
animationFrame = requestAnimationFrame(scrollTick);
cancelFrame(animationFrame);
animationFrame = requestFrame(scrollTick);

@@ -258,0 +299,0 @@ }

119

dist/dom-autoscroller.js

@@ -654,2 +654,43 @@ var autoScroll = (function () {

var prefix = [ 'webkit', 'moz', 'ms', 'o' ];
var window$1 = typeof window$1 !== "undefined" ? window$1 : {};
var requestFrame = (function () {
for ( var i = 0, limit = prefix.length ; i < limit && ! window$1.requestAnimationFrame ; ++i ) {
window$1.requestAnimationFrame = window$1[ prefix[ i ] + 'RequestAnimationFrame' ];
}
if ( ! window$1.requestAnimationFrame ) {
var lastTime = 0;
window$1.requestAnimationFrame = function (callback) {
var now = new Date().getTime();
var ttc = Math.max( 0, 16 - now - lastTime );
var timer = window$1.setTimeout( function () { return callback( now + ttc ); }, ttc );
lastTime = now + ttc;
return timer;
};
}
return window$1.requestAnimationFrame.bind( window$1 );
})();
var cancelFrame = (function () {
for ( var i = 0, limit = prefix.length ; i < limit && ! window$1.cancelAnimationFrame ; ++i ) {
window$1.cancelAnimationFrame = window$1[ prefix[ i ] + 'CancelAnimationFrame' ] || window$1[ prefix[ i ] + 'CancelRequestAnimationFrame' ];
}
if ( ! window$1.cancelAnimationFrame ) {
window$1.cancelAnimationFrame = function (timer) {
window$1.clearTimeout( timer );
};
}
return window$1.cancelAnimationFrame.bind( window$1 );
})();
function AutoScroller(elements, options){

@@ -670,4 +711,4 @@ if ( options === void 0 ) options = {};

window.addEventListener('mousemove', pointCB, false);
window.addEventListener('touchmove', pointCB, false);
window$1.addEventListener('mousemove', pointCB, false);
window$1.addEventListener('touchmove', pointCB, false);

@@ -682,15 +723,15 @@ if(!isNaN(options.maxSpeed)){

this.destroy = function(forceCleanAnimation) {
window.removeEventListener('mousemove', pointCB, false);
window.removeEventListener('touchmove', pointCB, false);
window.removeEventListener('mousedown', onDown, false);
window.removeEventListener('touchstart', onDown, false);
window.removeEventListener('mouseup', onUp, false);
window.removeEventListener('touchend', onUp, false);
window.removeEventListener('pointerup', onUp, false);
window.removeEventListener('mouseleave', onMouseOut, false);
window$1.removeEventListener('mousemove', pointCB, false);
window$1.removeEventListener('touchmove', pointCB, false);
window$1.removeEventListener('mousedown', onDown, false);
window$1.removeEventListener('touchstart', onDown, false);
window$1.removeEventListener('mouseup', onUp, false);
window$1.removeEventListener('touchend', onUp, false);
window$1.removeEventListener('pointerup', onUp, false);
window$1.removeEventListener('mouseleave', onMouseOut, false);
window.removeEventListener('mousemove', onMove, false);
window.removeEventListener('touchmove', onMove, false);
window$1.removeEventListener('mousemove', onMove, false);
window$1.removeEventListener('touchmove', onMove, false);
window.removeEventListener('scroll', setScroll, true);
window$1.removeEventListener('scroll', setScroll, true);
elements = [];

@@ -726,4 +767,4 @@ if(forceCleanAnimation){

temp.forEach(function(element){
if(element === window){
hasWindow = window;
if(element === window$1){
hasWindow = window$1;
}else{

@@ -752,6 +793,6 @@ self.add(element);

window.addEventListener('mousedown', onDown, false);
window.addEventListener('touchstart', onDown, false);
window.addEventListener('mouseup', onUp, false);
window.addEventListener('touchend', onUp, false);
window$1.addEventListener('mousedown', onDown, false);
window$1.addEventListener('touchstart', onDown, false);
window$1.addEventListener('mouseup', onUp, false);
window$1.addEventListener('touchend', onUp, false);

@@ -764,10 +805,10 @@ /*

*/
window.addEventListener('pointerup', onUp, false);
window$1.addEventListener('pointerup', onUp, false);
window.addEventListener('mousemove', onMove, false);
window.addEventListener('touchmove', onMove, false);
window$1.addEventListener('mousemove', onMove, false);
window$1.addEventListener('touchmove', onMove, false);
window.addEventListener('mouseleave', onMouseOut, false);
window$1.addEventListener('mouseleave', onMouseOut, false);
window.addEventListener('scroll', setScroll, true);
window$1.addEventListener('scroll', setScroll, true);

@@ -784,3 +825,3 @@ function setScroll(e){

if(scrolling){
requestAnimationFrame(function (){ return scrolling = false; });
requestFrame(function (){ return scrolling = false; });
}

@@ -798,4 +839,4 @@ }

function cleanAnimation(){
cancelAnimationFrame(animationFrame);
cancelAnimationFrame(windowAnimationFrame);
cancelFrame(animationFrame);
cancelFrame(windowAnimationFrame);
}

@@ -872,4 +913,4 @@ function onMouseOut(){

if(hasWindow){
cancelAnimationFrame(windowAnimationFrame);
windowAnimationFrame = requestAnimationFrame(scrollWindow);
cancelFrame(windowAnimationFrame);
windowAnimationFrame = requestFrame(scrollWindow);
}

@@ -882,4 +923,4 @@

cancelAnimationFrame(animationFrame);
animationFrame = requestAnimationFrame(scrollTick);
cancelFrame(animationFrame);
animationFrame = requestFrame(scrollTick);
}

@@ -890,4 +931,4 @@

cancelAnimationFrame(windowAnimationFrame);
windowAnimationFrame = requestAnimationFrame(scrollWindow);
cancelFrame(windowAnimationFrame);
windowAnimationFrame = requestFrame(scrollWindow);
}

@@ -903,4 +944,4 @@

cancelAnimationFrame(animationFrame);
animationFrame = requestAnimationFrame(scrollTick);
cancelFrame(animationFrame);
animationFrame = requestFrame(scrollTick);

@@ -966,4 +1007,4 @@ }

function scrollY(el, amount){
if(el === window){
window.scrollTo(el.pageXOffset, el.pageYOffset + amount);
if(el === window$1){
window$1.scrollTo(el.pageXOffset, el.pageYOffset + amount);
}else{

@@ -975,4 +1016,4 @@ el.scrollTop += amount;

function scrollX(el, amount){
if(el === window){
window.scrollTo(el.pageXOffset + amount, el.pageYOffset);
if(el === window$1){
window$1.scrollTo(el.pageXOffset + amount, el.pageYOffset);
}else{

@@ -979,0 +1020,0 @@ el.scrollLeft += amount;

@@ -1,1 +0,1 @@

var autoScroll=function(){"use strict";function e(e,t){return void 0===e?void 0===t?e:t:e}function t(t,n){return t=e(t,n),"function"==typeof t?function(){for(var e=arguments,n=arguments.length,r=Array(n),o=0;o<n;o++)r[o]=e[o];return!!t.apply(this,r)}:t?function(){return!0}:function(){return!1}}function n(e,t){if(t=u(t,!0),!b(t))return-1;for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1}function r(e,t){return-1!==n(e,t)}function o(e,t){for(var n=0;n<t.length;n++)r(e,t[n])||e.push(t[n]);return t}function i(e){for(var t=arguments,n=[],r=arguments.length-1;r-- >0;)n[r]=t[r+1];return n=n.map(u),o(e,n)}function a(e){for(var t=arguments,r=[],o=arguments.length-1;o-- >0;)r[o]=t[o+1];return r.map(u).reduce(function(t,r){var o=n(e,r);return-1!==o?t.concat(e.splice(o,1)):t},[])}function u(e,t){if("string"==typeof e)try{return document.querySelector(e)}catch(e){throw e}if(!b(e)&&!t)throw new TypeError(e+" is not a DOM element.");return e}function c(e,n){n=n||{};var r=t(n.allowUpdate,!0);return function(t){if(t=t||window.event,e.target=t.target||t.srcElement||t.originalTarget,e.element=this,e.type=t.type,r(t)){if(t.targetTouches)e.x=t.targetTouches[0].clientX,e.y=t.targetTouches[0].clientY,e.pageX=t.targetTouches[0].pageX,e.pageY=t.targetTouches[0].pageY,e.screenX=t.targetTouches[0].screenX,e.screenY=t.targetTouches[0].screenY;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,e.screenX=t.screenX,e.screenY=t.screenY}e.clientX=e.x,e.clientY=e.y}}}function l(){var e={top:{value:0,enumerable:!0},left:{value:0,enumerable:!0},right:{value:window.innerWidth,enumerable:!0},bottom:{value:window.innerHeight,enumerable:!0},width:{value:window.innerWidth,enumerable:!0},height:{value:window.innerHeight,enumerable:!0},x:{value:0,enumerable:!0},y:{value:0,enumerable:!0}};if(Object.create)return Object.create({},e);var t={};return Object.defineProperties(t,e),t}function f(e){if(e===window)return l();try{var t=e.getBoundingClientRect();return void 0===t.x&&(t.x=t.left,t.y=t.top),t}catch(t){throw new TypeError("Can't call getBoundingClientRect on "+e)}}function s(e,t){var n=f(t);return e.y>n.top&&e.y<n.bottom&&e.x>n.left&&e.x<n.right}function m(e){function t(e){for(var t=0;t<X.length;t++)r[X[t]]=e[X[t]]}function n(){e&&e.removeEventListener("mousemove",t,!1),r=null}var r={screenX:0,screenY:0,clientX:0,clientY:0,ctrlKey:!1,shiftKey:!1,altKey:!1,metaKey:!1,button:0,buttons:1,relatedTarget:null,region:null};return void 0!==e&&e.addEventListener("mousemove",t),{destroy:n,dispatch:function(){return MouseEvent?function(e,t,n){var o=new MouseEvent("mousemove",d(r,t));return v(o,n),e.dispatchEvent(o)}:"function"==typeof document.createEvent?function(e,t,n){var o=d(r,t),i=document.createEvent("MouseEvents");return i.initMouseEvent("mousemove",!0,!0,window,0,o.screenX,o.screenY,o.clientX,o.clientY,o.ctrlKey,o.altKey,o.shiftKey,o.metaKey,o.button,o.relatedTarget),v(i,n),e.dispatchEvent(i)}:"function"==typeof document.createEventObject?function(e,t,n){var o=document.createEventObject(),i=d(r,t);for(var a in i)o[a]=i[a];return v(o,n),e.dispatchEvent(o)}:void 0}()}}function d(e,t){t=t||{};for(var n=L(e),r=0;r<X.length;r++)void 0!==t[X[r]]&&(n[X[r]]=t[X[r]]);return n}function v(e,t){console.log("data ",t),e.data=t||{},e.dispatched="mousemove"}function p(e,n){function o(t){for(var n=0;n<e.length;n++)if(e[n]===t.target){T=!0;break}T&&requestAnimationFrame(function(){return T=!1})}function u(){j=!0}function l(){j=!1,s()}function s(){cancelAnimationFrame(F),cancelAnimationFrame(A)}function d(){j=!1}function v(t){if(!t)return null;if(K===t)return t;if(r(e,t))return t;for(;t=t.parentNode;)if(r(e,t))return t;return null}function p(){for(var t=null,n=0;n<e.length;n++)h(Y,e[n])&&(t=e[n]);return t}function w(e){if(X.autoScroll()&&!e.dispatched){var t=e.target,n=document.body;K&&!h(Y,K)&&(X.scrollWhenOutside||(K=null)),t&&t.parentNode===n?t=p():(t=v(t))||(t=p()),t&&t!==K&&(K=t),M&&(cancelAnimationFrame(A),A=requestAnimationFrame(y)),K&&(cancelAnimationFrame(F),F=requestAnimationFrame(g))}}function y(){b(M),cancelAnimationFrame(A),A=requestAnimationFrame(y)}function g(){K&&(b(K),cancelAnimationFrame(F),F=requestAnimationFrame(g))}function b(e){var t,n,r=f(e);t=Y.x<r.left+X.margin?Math.floor(Math.max(-1,(Y.x-r.left)/X.margin-1)*X.maxSpeed):Y.x>r.right-X.margin?Math.ceil(Math.min(1,(Y.x-r.right)/X.margin+1)*X.maxSpeed):0,n=Y.y<r.top+X.margin?Math.floor(Math.max(-1,(Y.y-r.top)/X.margin-1)*X.maxSpeed):Y.y>r.bottom-X.margin?Math.ceil(Math.min(1,(Y.y-r.bottom)/X.margin+1)*X.maxSpeed):0,X.syncMove()&&S.dispatch(e,{pageX:Y.pageX+t,pageY:Y.pageY+n,clientX:Y.x+t,clientY:Y.y+n}),setTimeout(function(){n&&E(e,n),t&&L(e,t)})}function E(e,t){e===window?window.scrollTo(e.pageXOffset,e.pageYOffset+t):e.scrollTop+=t}function L(e,t){e===window?window.scrollTo(e.pageXOffset+t,e.pageYOffset):e.scrollLeft+=t}void 0===n&&(n={});var X=this,x=4,T=!1;this.margin=n.margin||-1,this.scrollWhenOutside=n.scrollWhenOutside||!1;var Y={},O=c(Y),S=m(),j=!1;window.addEventListener("mousemove",O,!1),window.addEventListener("touchmove",O,!1),isNaN(n.maxSpeed)||(x=n.maxSpeed),this.autoScroll=t(n.autoScroll),this.syncMove=t(n.syncMove,!1),this.destroy=function(t){window.removeEventListener("mousemove",O,!1),window.removeEventListener("touchmove",O,!1),window.removeEventListener("mousedown",u,!1),window.removeEventListener("touchstart",u,!1),window.removeEventListener("mouseup",l,!1),window.removeEventListener("touchend",l,!1),window.removeEventListener("pointerup",l,!1),window.removeEventListener("mouseleave",d,!1),window.removeEventListener("mousemove",w,!1),window.removeEventListener("touchmove",w,!1),window.removeEventListener("scroll",o,!0),e=[],t&&s()},this.add=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return i.apply(void 0,[e].concat(t)),this},this.remove=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return a.apply(void 0,[e].concat(t))};var A,M=null;"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),function(t){e=[],t.forEach(function(e){e===window?M=window:X.add(e)})}(e),Object.defineProperties(this,{down:{get:function(){return j}},maxSpeed:{get:function(){return x}},point:{get:function(){return Y}},scrolling:{get:function(){return T}}});var F,K=null;window.addEventListener("mousedown",u,!1),window.addEventListener("touchstart",u,!1),window.addEventListener("mouseup",l,!1),window.addEventListener("touchend",l,!1),window.addEventListener("pointerup",l,!1),window.addEventListener("mousemove",w,!1),window.addEventListener("touchmove",w,!1),window.addEventListener("mouseleave",d,!1),window.addEventListener("scroll",o,!0)}function w(e,t){return new p(e,t)}function h(e,t,n){return n?e.y>n.top&&e.y<n.bottom&&e.x>n.left&&e.x<n.right:s(e,t)}var y=function(){var e=function(e){return"function"==typeof e},t=function(e){var t=Number(e);return isNaN(t)?0:0!==t&&isFinite(t)?(t>0?1:-1)*Math.floor(Math.abs(t)):t},n=Math.pow(2,53)-1,r=function(e){var r=t(e);return Math.min(Math.max(r,0),n)},o=function(e){if(null!=e){if(["string","number","boolean","symbol"].indexOf(typeof e)>-1)return Symbol.iterator;if("undefined"!=typeof Symbol&&"iterator"in Symbol&&Symbol.iterator in e)return Symbol.iterator;if("@@iterator"in e)return"@@iterator"}},i=function(t,n){if(null!=t&&null!=n){var r=t[n];if(null==r)return;if(!e(r))throw new TypeError(r+" is not a function");return r}},a=function(e){var t=e.next();return!Boolean(t.done)&&t};return function(t){var n,u=this,c=arguments.length>1?arguments[1]:void 0;if(void 0!==c){if(!e(c))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(n=arguments[2])}var l,f,s=i(t,o(t));if(void 0!==s){l=e(u)?Object(new u):[];var m=s.call(t);if(null==m)throw new TypeError("Array.from requires an array-like or iterable object");f=0;for(var d,v;;){if(!(d=a(m)))return l.length=f,l;v=d.value,l[f]=c?c.call(n,v,f):v,f++}}else{var p=Object(t);if(null==t)throw new TypeError("Array.from requires an array-like object - not null or undefined");var w=r(p.length);l=e(u)?Object(new u(w)):new Array(w),f=0;for(var h;f<w;)h=p[f],l[f]=c?c.call(n,h,f):h,f++;l.length=w}return l}}(),g=("function"==typeof Array.from&&Array.from,Array.isArray,Object.prototype.toString,"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}),b=function(e){return null!=e&&"object"===(void 0===e?"undefined":g(e))&&1===e.nodeType&&"object"===g(e.style)&&"object"===g(e.ownerDocument)},E=void 0;E="function"!=typeof Object.create?function(e){var t=function(){};return function(e,n){if(e!==Object(e)&&null!==e)throw TypeError("Argument must be an object, or null");t.prototype=e||{};var r=new t;return t.prototype=null,void 0!==n&&Object.defineProperties(r,n),null===e&&(r.__proto__=null),r}}():Object.create;var L=E,X=["altKey","button","buttons","clientX","clientY","ctrlKey","metaKey","movementX","movementY","offsetX","offsetY","pageX","pageY","region","relatedTarget","screenX","screenY","shiftKey","which","x","y"];return w}();
var autoScroll=function(){"use strict";function e(e,t){return void 0===e?void 0===t?e:t:e}function t(t,n){return t=e(t,n),"function"==typeof t?function(){for(var e=arguments,n=arguments.length,r=Array(n),o=0;o<n;o++)r[o]=e[o];return!!t.apply(this,r)}:t?function(){return!0}:function(){return!1}}function n(e,t){if(t=u(t,!0),!w(t))return-1;for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1}function r(e,t){return-1!==n(e,t)}function o(e,t){for(var n=0;n<t.length;n++)r(e,t[n])||e.push(t[n]);return t}function i(e){for(var t=arguments,n=[],r=arguments.length-1;r-- >0;)n[r]=t[r+1];return n=n.map(u),o(e,n)}function a(e){for(var t=arguments,r=[],o=arguments.length-1;o-- >0;)r[o]=t[o+1];return r.map(u).reduce(function(t,r){var o=n(e,r);return-1!==o?t.concat(e.splice(o,1)):t},[])}function u(e,t){if("string"==typeof e)try{return document.querySelector(e)}catch(e){throw e}if(!w(e)&&!t)throw new TypeError(e+" is not a DOM element.");return e}function c(e,n){n=n||{};var r=t(n.allowUpdate,!0);return function(t){if(t=t||window.event,e.target=t.target||t.srcElement||t.originalTarget,e.element=this,e.type=t.type,r(t)){if(t.targetTouches)e.x=t.targetTouches[0].clientX,e.y=t.targetTouches[0].clientY,e.pageX=t.targetTouches[0].pageX,e.pageY=t.targetTouches[0].pageY,e.screenX=t.targetTouches[0].screenX,e.screenY=t.targetTouches[0].screenY;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,e.screenX=t.screenX,e.screenY=t.screenY}e.clientX=e.x,e.clientY=e.y}}}function l(){var e={top:{value:0,enumerable:!0},left:{value:0,enumerable:!0},right:{value:window.innerWidth,enumerable:!0},bottom:{value:window.innerHeight,enumerable:!0},width:{value:window.innerWidth,enumerable:!0},height:{value:window.innerHeight,enumerable:!0},x:{value:0,enumerable:!0},y:{value:0,enumerable:!0}};if(Object.create)return Object.create({},e);var t={};return Object.defineProperties(t,e),t}function f(e){if(e===window)return l();try{var t=e.getBoundingClientRect();return void 0===t.x&&(t.x=t.left,t.y=t.top),t}catch(t){throw new TypeError("Can't call getBoundingClientRect on "+e)}}function s(e,t){var n=f(t);return e.y>n.top&&e.y<n.bottom&&e.x>n.left&&e.x<n.right}function m(e){function t(e){for(var t=0;t<x.length;t++)r[x[t]]=e[x[t]]}function n(){e&&e.removeEventListener("mousemove",t,!1),r=null}var r={screenX:0,screenY:0,clientX:0,clientY:0,ctrlKey:!1,shiftKey:!1,altKey:!1,metaKey:!1,button:0,buttons:1,relatedTarget:null,region:null};return void 0!==e&&e.addEventListener("mousemove",t),{destroy:n,dispatch:function(){return MouseEvent?function(e,t,n){var o=new MouseEvent("mousemove",v(r,t));return d(o,n),e.dispatchEvent(o)}:"function"==typeof document.createEvent?function(e,t,n){var o=v(r,t),i=document.createEvent("MouseEvents");return i.initMouseEvent("mousemove",!0,!0,window,0,o.screenX,o.screenY,o.clientX,o.clientY,o.ctrlKey,o.altKey,o.shiftKey,o.metaKey,o.button,o.relatedTarget),d(i,n),e.dispatchEvent(i)}:"function"==typeof document.createEventObject?function(e,t,n){var o=document.createEventObject(),i=v(r,t);for(var a in i)o[a]=i[a];return d(o,n),e.dispatchEvent(o)}:void 0}()}}function v(e,t){t=t||{};for(var n=T(e),r=0;r<x.length;r++)void 0!==t[x[r]]&&(n[x[r]]=t[x[r]]);return n}function d(e,t){console.log("data ",t),e.data=t||{},e.dispatched="mousemove"}function p(e,n){function o(t){for(var n=0;n<e.length;n++)if(e[n]===t.target){O=!0;break}O&&Y(function(){return O=!1})}function u(){F=!0}function l(){F=!1,s()}function s(){A(N),A(K)}function v(){F=!1}function d(t){if(!t)return null;if(C===t)return t;if(r(e,t))return t;for(;t=t.parentNode;)if(r(e,t))return t;return null}function p(){for(var t=null,n=0;n<e.length;n++)g(S,e[n])&&(t=e[n]);return t}function h(e){if(x.autoScroll()&&!e.dispatched){var t=e.target,n=document.body;C&&!g(S,C)&&(x.scrollWhenOutside||(C=null)),t&&t.parentNode===n?t=p():(t=d(t))||(t=p()),t&&t!==C&&(C=t),q&&(A(K),K=Y(y)),C&&(A(N),N=Y(b))}}function y(){w(q),A(K),K=Y(y)}function b(){C&&(w(C),A(N),N=Y(b))}function w(e){var t,n,r=f(e);t=S.x<r.left+x.margin?Math.floor(Math.max(-1,(S.x-r.left)/x.margin-1)*x.maxSpeed):S.x>r.right-x.margin?Math.ceil(Math.min(1,(S.x-r.right)/x.margin+1)*x.maxSpeed):0,n=S.y<r.top+x.margin?Math.floor(Math.max(-1,(S.y-r.top)/x.margin-1)*x.maxSpeed):S.y>r.bottom-x.margin?Math.ceil(Math.min(1,(S.y-r.bottom)/x.margin+1)*x.maxSpeed):0,x.syncMove()&&M.dispatch(e,{pageX:S.pageX+t,pageY:S.pageY+n,clientX:S.x+t,clientY:S.y+n}),setTimeout(function(){n&&E(e,n),t&&T(e,t)})}function E(e,t){e===X?X.scrollTo(e.pageXOffset,e.pageYOffset+t):e.scrollTop+=t}function T(e,t){e===X?X.scrollTo(e.pageXOffset+t,e.pageYOffset):e.scrollLeft+=t}void 0===n&&(n={});var x=this,L=4,O=!1;this.margin=n.margin||-1,this.scrollWhenOutside=n.scrollWhenOutside||!1;var S={},j=c(S),M=m(),F=!1;X.addEventListener("mousemove",j,!1),X.addEventListener("touchmove",j,!1),isNaN(n.maxSpeed)||(L=n.maxSpeed),this.autoScroll=t(n.autoScroll),this.syncMove=t(n.syncMove,!1),this.destroy=function(t){X.removeEventListener("mousemove",j,!1),X.removeEventListener("touchmove",j,!1),X.removeEventListener("mousedown",u,!1),X.removeEventListener("touchstart",u,!1),X.removeEventListener("mouseup",l,!1),X.removeEventListener("touchend",l,!1),X.removeEventListener("pointerup",l,!1),X.removeEventListener("mouseleave",v,!1),X.removeEventListener("mousemove",h,!1),X.removeEventListener("touchmove",h,!1),X.removeEventListener("scroll",o,!0),e=[],t&&s()},this.add=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return i.apply(void 0,[e].concat(t)),this},this.remove=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return a.apply(void 0,[e].concat(t))};var K,q=null;"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),function(t){e=[],t.forEach(function(e){e===X?q=X:x.add(e)})}(e),Object.defineProperties(this,{down:{get:function(){return F}},maxSpeed:{get:function(){return L}},point:{get:function(){return S}},scrolling:{get:function(){return O}}});var N,C=null;X.addEventListener("mousedown",u,!1),X.addEventListener("touchstart",u,!1),X.addEventListener("mouseup",l,!1),X.addEventListener("touchend",l,!1),X.addEventListener("pointerup",l,!1),X.addEventListener("mousemove",h,!1),X.addEventListener("touchmove",h,!1),X.addEventListener("mouseleave",v,!1),X.addEventListener("scroll",o,!0)}function h(e,t){return new p(e,t)}function g(e,t,n){return n?e.y>n.top&&e.y<n.bottom&&e.x>n.left&&e.x<n.right:s(e,t)}var y=function(){var e=function(e){return"function"==typeof e},t=function(e){var t=Number(e);return isNaN(t)?0:0!==t&&isFinite(t)?(t>0?1:-1)*Math.floor(Math.abs(t)):t},n=Math.pow(2,53)-1,r=function(e){var r=t(e);return Math.min(Math.max(r,0),n)},o=function(e){if(null!=e){if(["string","number","boolean","symbol"].indexOf(typeof e)>-1)return Symbol.iterator;if("undefined"!=typeof Symbol&&"iterator"in Symbol&&Symbol.iterator in e)return Symbol.iterator;if("@@iterator"in e)return"@@iterator"}},i=function(t,n){if(null!=t&&null!=n){var r=t[n];if(null==r)return;if(!e(r))throw new TypeError(r+" is not a function");return r}},a=function(e){var t=e.next();return!Boolean(t.done)&&t};return function(t){var n,u=this,c=arguments.length>1?arguments[1]:void 0;if(void 0!==c){if(!e(c))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(n=arguments[2])}var l,f,s=i(t,o(t));if(void 0!==s){l=e(u)?Object(new u):[];var m=s.call(t);if(null==m)throw new TypeError("Array.from requires an array-like or iterable object");f=0;for(var v,d;;){if(!(v=a(m)))return l.length=f,l;d=v.value,l[f]=c?c.call(n,d,f):d,f++}}else{var p=Object(t);if(null==t)throw new TypeError("Array.from requires an array-like object - not null or undefined");var h=r(p.length);l=e(u)?Object(new u(h)):new Array(h),f=0;for(var g;f<h;)g=p[f],l[f]=c?c.call(n,g,f):g,f++;l.length=h}return l}}(),b=("function"==typeof Array.from&&Array.from,Array.isArray,Object.prototype.toString,"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}),w=function(e){return null!=e&&"object"===(void 0===e?"undefined":b(e))&&1===e.nodeType&&"object"===b(e.style)&&"object"===b(e.ownerDocument)},E=void 0;E="function"!=typeof Object.create?function(e){var t=function(){};return function(e,n){if(e!==Object(e)&&null!==e)throw TypeError("Argument must be an object, or null");t.prototype=e||{};var r=new t;return t.prototype=null,void 0!==n&&Object.defineProperties(r,n),null===e&&(r.__proto__=null),r}}():Object.create;var T=E,x=["altKey","button","buttons","clientX","clientY","ctrlKey","metaKey","movementX","movementY","offsetX","offsetY","pageX","pageY","region","relatedTarget","screenX","screenY","shiftKey","which","x","y"],L=["webkit","moz","ms","o"],X=void 0!==X?X:{},Y=function(){for(var e=0,t=L.length;e<t&&!X.requestAnimationFrame;++e)X.requestAnimationFrame=X[L[e]+"RequestAnimationFrame"];if(!X.requestAnimationFrame){var n=0;X.requestAnimationFrame=function(e){var t=(new Date).getTime(),r=Math.max(0,16-t-n),o=X.setTimeout(function(){return e(t+r)},r);return n=t+r,o}}return X.requestAnimationFrame.bind(X)}(),A=function(){for(var e=0,t=L.length;e<t&&!X.cancelAnimationFrame;++e)X.cancelAnimationFrame=X[L[e]+"CancelAnimationFrame"]||X[L[e]+"CancelRequestAnimationFrame"];return X.cancelAnimationFrame||(X.cancelAnimationFrame=function(e){X.clearTimeout(e)}),X.cancelAnimationFrame.bind(X)}();return h}();
{
"name": "@mattlewis92/dom-autoscroller",
"version": "2.3.4",
"version": "2.3.5",
"description": "Auto scroll dom elements",

@@ -21,3 +21,2 @@ "main": "dist/bundle.js",

"dependencies": {
"animation-frame-polyfill": "^1.0.0",
"create-point-cb": "^1.0.0",

@@ -24,0 +23,0 @@ "dom-mousemove-dispatcher": "^1.0.1",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc