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