-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbase.min.js
1 lines (1 loc) · 1.31 KB
/
base.min.js
1
"use strict";export default function(e,t,n,i){var o,u,r,s,c={},v=0,a=0,l=(i={...{sensitivity:10,interval:100,timeout:0,handleFocus:!1},...i},!1),m=!1;function f(e){o=e.clientX,u=e.clientY}function d(n){return m=!0,a&&(a=clearTimeout(a)),e.removeEventListener("mousemove",f,!1),1!==v&&(r=n.clientX,s=n.clientY,e.addEventListener("mousemove",f,!1),a=setTimeout(function(){!function e(n,c){if(a&&(a=clearTimeout(a)),Math.abs(r-o)+Math.abs(s-u)<i.sensitivity)return v=1,l?void 0:t.call(n,c);r=o,s=u,a=setTimeout(function(){e(n,c)},i.interval)}(e,n)},i.interval)),this}function E(t){return m=!1,a&&(a=clearTimeout(a)),e.removeEventListener("mousemove",f,!1),1===v&&(a=setTimeout(function(){!function(e,t){a&&(a=clearTimeout(a)),v=0,l||n.call(e,t)}(e,t)},i.timeout)),this}function L(n){m||(l=!0,t.call(e,n))}function h(t){!m&&l&&(l=!1,n.call(e,t))}function T(){e.removeEventListener("focus",L,!1),e.removeEventListener("blur",h,!1)}return c.options=function(t){var n=t.handleFocus!==i.handleFocus;return i=Object.assign({},i,t),n&&(i.handleFocus?(e.addEventListener("focus",L,!1),e.addEventListener("blur",h,!1)):T()),c},c.remove=function(){e&&(e.removeEventListener("mouseover",d,!1),e.removeEventListener("mouseout",E,!1),T())},c.manualReset=function(){v=1,E()},e&&(e.addEventListener("mouseover",d,!1),e.addEventListener("mouseout",E,!1)),c};