UNPKG

@appinfini/react-cursor-position

Version:

A React component that decorates its children with touch and mouse cursor coordinates, plotted relative to itself.

30 lines 26.6 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactCursorPosition=t(require("react")):e.ReactCursorPosition=t(e.React)}("undefined"!=typeof self?self:this,function(e){return function(e){function t(o){if(n[o])return n[o].exports;var i=n[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(e,t,n){"use strict";n.d(t,"c",function(){return o}),n.d(t,"e",function(){return i}),n.d(t,"b",function(){return r}),n.d(t,"d",function(){return s}),n.d(t,"f",function(){return a}),n.d(t,"a",function(){return u});var o="pressEvent",i="tap",r="mouseEmulation",s="setHovering",a="unsetHovering",u={TOUCH:"touch",TAP:"tap",DOUBLE_TAP:"double_tap",PRESS:"press",CLICK:"click",HOVER:"hover"}},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=n(2),a=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),u=function(e){function t(e){var n=e.onIsActiveChanged;o(this,t);var r=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,{onIsActiveChanged:n}));return r.initialElTop=0,r.currentElTop=0,r}return r(t,e),a(t,[{key:"touchStarted",value:function(){}},{key:"touchMoved",value:function(){}},{key:"touchEnded",value:function(){this.deactivate()}},{key:"touchCanceled",value:function(){this.deactivate()}}]),t}(s.a);t.a=u},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),r=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onIsActiveChanged;if(o(this,e),"function"!=typeof n)throw new Error("onIsActiveChanged should be a function");this.onIsActiveChanged=n,this.isActive=!1,this.timers=[]}return i(e,[{key:"activate",value:function(){this.isActive=!0,this.onIsActiveChanged({isActive:!0})}},{key:"deactivate",value:function(){this.isActive=!1,this.onIsActiveChanged({isActive:!1}),this.clearTimers()}},{key:"toggleActivation",value:function(){this.isActive?this.deactivate():this.activate()}},{key:"clearTimers",value:function(){for(var e=this.timers;e.length;){var t=e.pop();clearTimeout(t.id)}}},{key:"clearTimer",value:function(e){this.timers.forEach(function(t){t.name===e&&clearTimeout(t.id)})}}]),e}();t.a=r},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=n(2),a=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),u=function(e){function t(e){var n=e.onIsActiveChanged;return o(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,{onIsActiveChanged:n}))}return r(t,e),a(t,[{key:"mouseEntered",value:function(){}},{key:"mouseMoved",value:function(){}},{key:"mouseLeft",value:function(){}},{key:"mouseClicked",value:function(){}}]),t}(s.a);t.a=u},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=n(5),a=n.n(s),u=n(6),c=n.n(u),h=n(9),l=n.n(h),f=n(10),v=n.n(f),p=n(14),d=n(15),y=n(0),b=n(16),m=n(17),g=n(18),O=n(19),E=n(20),T=n(21);n.d(t,"INTERACTIONS",function(){return y.a});var C=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),P=function(e){function t(e){o(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return k.call(n),n.state={detectedEnvironment:{isMouseDetected:!1,isTouchDetected:!1},elementDimensions:{width:0,height:0},isActive:!1,isPositionOutside:!0,position:{x:0,y:0}},n.shouldGuardAgainstMouseEmulationByDevices=!1,n.eventListeners=[],n.timers=[],n.elementOffset={x:0,y:0},n.onTouchStart=n.onTouchStart.bind(n),n.onTouchMove=n.onTouchMove.bind(n),n.onTouchEnd=n.onTouchEnd.bind(n),n.onTouchCancel=n.onTouchCancel.bind(n),n.onMouseEnter=n.onMouseEnter.bind(n),n.onMouseMove=n.onMouseMove.bind(n),n.onMouseLeave=n.onMouseLeave.bind(n),n.onClick=n.onClick.bind(n),n.onIsActiveChanged=n.onIsActiveChanged.bind(n),n.setTouchActivationStrategy(e.activationInteractionTouch),n.setMouseActivationStrategy(e.activationInteractionMouse),n}return r(t,e),C(t,[{key:"onIsActiveChanged",value:function(e){e.isActive?this.activate():this.deactivate()}},{key:"onTouchStart",value:function(e){this.init(),this.onTouchDetected(),this.setShouldGuardAgainstMouseEmulationByDevices();var t=this.core.getCursorPosition(this.getTouchEvent(e));this.setPositionState(t),this.touchActivation.touchStarted({e:e,position:t})}},{key:"onTouchMove",value:function(e){if(this.isCoreReady){var t=this.core.getCursorPosition(this.getTouchEvent(e));this.touchActivation.touchMoved({e:e,position:t}),this.state.isActive&&(this.setPositionState(t),e.preventDefault(),this.props.shouldStopTouchMovePropagation&&e.stopPropagation())}}},{key:"onTouchEnd",value:function(){this.touchActivation.touchEnded(),this.unsetShouldGuardAgainstMouseEmulationByDevices()}},{key:"onTouchCancel",value:function(){this.touchActivation.touchCanceled(),this.unsetShouldGuardAgainstMouseEmulationByDevices()}},{key:"onMouseEnter",value:function(e){this.shouldGuardAgainstMouseEmulationByDevices||(this.init(),this.onMouseDetected(),this.setPositionState(this.core.getCursorPosition(e)),this.mouseActivation.mouseEntered())}},{key:"onMouseMove",value:function(e){if(this.isCoreReady){var t=this.core.getCursorPosition(e);this.setPositionState(t),this.mouseActivation.mouseMoved(t)}}},{key:"onMouseLeave",value:function(){this.mouseActivation.mouseLeft(),this.setState({isPositionOutside:!0})}},{key:"onClick",value:function(e){this.setPositionState(this.core.getCursorPosition(e)),this.mouseActivation.mouseClicked(),this.onMouseDetected()}},{key:"onTouchDetected",value:function(){var e={isTouchDetected:!0,isMouseDetected:!1};this.setState({detectedEnvironment:e}),this.props.onDetectedEnvironmentChanged(e)}},{key:"onMouseDetected",value:function(){var e={isTouchDetected:!1,isMouseDetected:!0};this.setState({detectedEnvironment:e}),this.props.onDetectedEnvironmentChanged(e)}},{key:"componentDidMount",value:function(){this.props.isEnabled&&this.enable()}},{key:"UNSAFE_componentWillReceiveProps",value:function(e){var t=e.isEnabled;this.props.isEnabled!==t&&(t?this.enable():this.disable())}},{key:"componentWillUnmount",value:function(){this.disable()}},{key:"enable",value:function(){this.addEventListeners()}},{key:"disable",value:function(){this.removeEventListeners()}},{key:"init",value:function(){this.core=new p.a(this.el),this.setElementDimensionsState(this.getElementDimensions(this.el))}},{key:"setTouchActivationStrategy",value:function(e){var t=this.props,n=t.pressDurationInMs,o=t.pressMoveThreshold,i=t.tapDurationInMs,r=t.tapMoveThreshold,s=y.a.TOUCH,a=y.a.TAP,u=y.a.PRESS;switch(e){case u:this.touchActivation=new m.a({onIsActiveChanged:this.onIsActiveChanged,pressDurationInMs:n,pressMoveThreshold:o});break;case a:this.touchActivation=new O.a({onIsActiveChanged:this.onIsActiveChanged,tapDurationInMs:i,tapMoveThreshold:r});break;case s:this.touchActivation=new g.a({onIsActiveChanged:this.onIsActiveChanged});break;default:throw new Error("Must implement a touch activation strategy")}}},{key:"setMouseActivationStrategy",value:function(e){var t=this.props,n=t.hoverDelayInMs,o=t.hoverOffDelayInMs,i=y.a.HOVER,r=y.a.CLICK;switch(e){case i:this.mouseActivation=new E.a({onIsActiveChanged:this.onIsActiveChanged,hoverDelayInMs:n,hoverOffDelayInMs:o});break;case r:this.mouseActivation=new T.a({onIsActiveChanged:this.onIsActiveChanged});break;default:throw new Error("Must implement a mouse activation strategy")}}},{key:"reset",value:function(){var e=this.core;e=void 0===e?{}:e;var t=e.lastEvent;this.init(),t&&this.setPositionState(this.core.getCursorPosition(t))}},{key:"activate",value:function(){this.setState({isActive:!0}),this.props.onActivationChanged({isActive:!0})}},{key:"deactivate",value:function(){var e=this;this.setState({isActive:!1},function(){var t=e.state,n=t.isPositionOutside,o=t.position;e.props.onPositionChanged({isPositionOutside:n,position:o}),e.props.onActivationChanged({isActive:!1})})}},{key:"setPositionState",value:function(e){var t=this.getIsPositionOutside(e);this.setState({isPositionOutside:t,position:e},this.onPositionChanged)}},{key:"setElementDimensionsState",value:function(e){this.setState({elementDimensions:e})}},{key:"setShouldGuardAgainstMouseEmulationByDevices",value:function(){this.shouldGuardAgainstMouseEmulationByDevices=!0}},{key:"unsetShouldGuardAgainstMouseEmulationByDevices",value:function(){var e=this;this.timers.push({name:y.b,id:setTimeout(function(){e.shouldGuardAgainstMouseEmulationByDevices=!1},0)})}},{key:"getElementDimensions",value:function(e){var t=e.getBoundingClientRect();return{width:t.width,height:t.height}}},{key:"getIsPositionOutside",value:function(e){var t=e.x,n=e.y,o=this.state.elementDimensions,i=o.width,r=o.height;return t<0||n<0||t>i||n>r}},{key:"getTouchEvent",value:function(e){return e.touches[0]}},{key:"getIsReactComponent",value:function(e){return"function"==typeof e.type}},{key:"shouldDecorateChild",value:function(e){return!!e&&this.getIsReactComponent(e)&&this.props.shouldDecorateChildren}},{key:"decorateChild",value:function(e,t){return Object(s.cloneElement)(e,t)}},{key:"decorateChildren",value:function(e,t){var n=this;return s.Children.map(e,function(e){return n.shouldDecorateChild(e)?n.decorateChild(e,t):e})}},{key:"addEventListeners",value:function(){this.eventListeners.push(Object(d.a)(this.el,"touchstart",this.onTouchStart,{passive:!1}),Object(d.a)(this.el,"touchmove",this.onTouchMove,{passive:!1}),Object(d.a)(this.el,"touchend",this.onTouchEnd),Object(d.a)(this.el,"touchcancel",this.onTouchCancel),Object(d.a)(this.el,"mouseenter",this.onMouseEnter),Object(d.a)(this.el,"mousemove",this.onMouseMove),Object(d.a)(this.el,"mouseleave",this.onMouseLeave),Object(d.a)(this.el,"click",this.onClick))}},{key:"removeEventListeners",value:function(){for(;this.eventListeners.length;)this.eventListeners.pop().removeEventListener()}},{key:"getPassThroughProps",value:function(){var e=Object.keys(this.constructor.propTypes||{});if(e.length)return v()(this.props,e)}},{key:"render",value:function(){var e=this,t=this.props,n=t.children,o=t.className,i=t.mapChildProps,r=t.style,s=l()({},i(this.state),this.getPassThroughProps());return a.a.createElement("div",{className:o,ref:function(t){return e.el=t},style:l()({},r,{WebkitUserSelect:"none"})},this.decorateChildren(n,s))}},{key:"isCoreReady",get:function(){return!!this.core}}]),t}(a.a.Component);P.displayName="ReactCursorPosition",P.propTypes={activationInteractionMouse:c.a.oneOf([y.a.CLICK,y.a.HOVER]),activationInteractionTouch:c.a.oneOf([y.a.PRESS,y.a.TAP,y.a.TOUCH]),children:c.a.any,className:c.a.string,hoverDelayInMs:c.a.number,hoverOffDelayInMs:c.a.number,isEnabled:c.a.bool,mapChildProps:c.a.func,onActivationChanged:c.a.func,onDetectedEnvironmentChanged:c.a.func,onPositionChanged:c.a.func,pressDurationInMs:c.a.number,pressMoveThreshold:c.a.number,shouldDecorateChildren:c.a.bool,shouldStopTouchMovePropagation:c.a.bool,style:c.a.object,tapDurationInMs:c.a.number,tapMoveThreshold:c.a.number},P.defaultProps={activationInteractionMouse:y.a.HOVER,activationInteractionTouch:y.a.PRESS,hoverDelayInMs:0,hoverOffDelayInMs:0,isEnabled:!0,mapChildProps:function(e){return e},onActivationChanged:b.a,onDetectedEnvironmentChanged:b.a,onPositionChanged:b.a,pressDurationInMs:500,pressMoveThreshold:5,shouldDecorateChildren:!0,shouldStopTouchMovePropagation:!1,tapDurationInMs:180,tapMoveThreshold:5};var k=function(){var e=this;this.onPositionChanged=function(){(0,e.props.onPositionChanged)(e.state)}};t.default=P},function(t,n){t.exports=e},function(e,t,n){e.exports=n(7)()},function(e,t,n){"use strict";function o(){}var i=n(8);e.exports=function(){function e(e,t,n,o,r,s){if(s!==i){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return n.checkPropTypes=o,n.PropTypes=n,n}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";function o(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}/* object-assign (c) Sindre Sorhus @license MIT */ var i=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(e){o[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,a,u=o(e),c=1;c<arguments.length;c++){n=Object(arguments[c]);for(var h in n)r.call(n,h)&&(u[h]=n[h]);if(i){a=i(n);for(var l=0;l<a.length;l++)s.call(n,a[l])&&(u[a[l]]=n[a[l]])}}return u}},function(e,t,n){"use strict";/*! * object.omit <https://github.com/jonschlinkert/object.omit> * * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */ var o=n(11);e.exports=function(e,t,n){if(!o(e))return{};"function"==typeof t&&(n=t,t=[]),"string"==typeof t&&(t=[t]);for(var i="function"==typeof n,r=Object.keys(e),s={},a=0;a<r.length;a++){var u=r[a],c=e[u];t&&(-1!==t.indexOf(u)||i&&!n(c,u,e))||(s[u]=c)}return s}},function(e,t,n){"use strict";/*! * is-extendable <https://github.com/jonschlinkert/is-extendable> * * Copyright (c) 2015-2017, Jon Schlinkert. * Released under the MIT License. */ var o=n(12);e.exports=function(e){return o(e)||"function"==typeof e||Array.isArray(e)}},function(e,t,n){"use strict";function o(e){return!0===i(e)&&"[object Object]"===Object.prototype.toString.call(e)}/*! * is-plain-object <https://github.com/jonschlinkert/is-plain-object> * * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */ var i=n(13);e.exports=function(e){var t,n;return!1!==o(e)&&("function"==typeof(t=e.constructor)&&(n=t.prototype,!1!==o(n)&&!1!==n.hasOwnProperty("isPrototypeOf")))}},function(e,t,n){"use strict";/*! * isobject <https://github.com/jonschlinkert/isobject> * * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */ e.exports=function(e){return null!=e&&"object"==typeof e&&!1===Array.isArray(e)}},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),r=function(){function e(t){o(this,e),this.el=t}return i(e,[{key:"getDocumentRelativeElementOffset",value:function(e){var t=this.getRootOfEl(e),n=t.getBoundingClientRect(),o=n.left,i=n.top,r=e.getBoundingClientRect(),s=r.left,a=r.top;return{x:Math.abs(o)+s,y:Math.abs(i)+a}}},{key:"getRootOfEl",value:function(e){return e.parentElement?this.getRootOfEl(e.parentElement):e}},{key:"getComputedElementRelativeCursorPosition",value:function(e,t){this.lastEvent=e;var n=this.getDocumentRelativeCursorPosition(e),o=n.x,i=n.y,r=t.x,s=t.y;return{x:Math.round(o-r),y:Math.round(i-s)}}},{key:"getDocumentRelativeCursorPosition",value:function(e){return{x:e.pageX,y:e.pageY}}},{key:"getCursorPosition",value:function(e){return this.getComputedElementRelativeCursorPosition(e,this.documentRelativeElementOffset)}},{key:"documentRelativeElementOffset",get:function(){return this.elementOffset||(this.elementOffset=this.getDocumentRelativeElementOffset(this.el)),this.elementOffset}}]),e}();t.a=r},function(e,t,n){"use strict";function o(e,t,n,o){return e.addEventListener(t,n,o),{removeEventListener:function(){e.removeEventListener(t,n,o)}}}t.a=o},function(e,t,n){"use strict";t.a=function(){}},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=n(0),a=n(1),u=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),c=function(e){function t(e){var n=e.onIsActiveChanged,r=e.pressDurationInMs,s=e.pressMoveThreshold;o(this,t);var a=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,{onIsActiveChanged:n}));return a.pressDurationInMs=r,a.pressMoveThreshold=s,a}return r(t,e),u(t,[{key:"touchStarted",value:function(e){var t=e.position;this.initPressEventCriteria(t),this.setPressEventTimer()}},{key:"touchMoved",value:function(e){var t=e.position;this.isActive||this.setPressEventCriteria(t)}},{key:"setPressEventTimer",value:function(){var e=this;this.timers.push({name:s.c,id:setTimeout(function(){Math.abs(e.currentElTop-e.initialElTop)<e.pressMoveThreshold&&e.activate()},this.pressDurationInMs)})}},{key:"setPressEventCriteria",value:function(e){this.currentElTop=e.y}},{key:"initPressEventCriteria",value:function(e){var t=e.y;this.initialElTop=t,this.currentElTop=t}}]),t}(a.a);t.a=c},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=n(1),a=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),u=function(e){function t(e){var n=e.onIsActiveChanged;return o(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,{onIsActiveChanged:n}))}return r(t,e),a(t,[{key:"touchStarted",value:function(e){e.e.preventDefault(),this.activate()}}]),t}(s.a);t.a=u},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=n(0),a=n(1),u=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),c=function(e){function t(e){var n=e.onIsActiveChanged,r=e.tapDurationInMs,s=e.tapMoveThreshold;o(this,t);var a=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,{onIsActiveChanged:n}));return a.hasTapGestureEnded=!1,a.tapDurationInMs=r,a.tapMoveThreshold=s,a}return r(t,e),u(t,[{key:"touchStarted",value:function(e){var t=e.position;this.hasTapGestureEnded=!1,this.initMoveThreshold(t),this.setTapEventTimer()}},{key:"touchMoved",value:function(e){var t=e.position;this.isActive||this.setMoveThresholdCriteria(t)}},{key:"touchEnded",value:function(){this.hasTapGestureEnded=!0}},{key:"setTapEventTimer",value:function(){var e=this;this.timers.push({name:s.e,id:setTimeout(function(){e.isTapGestureActive&&e.toggleActivation()},this.tapDurationInMs)})}},{key:"setMoveThresholdCriteria",value:function(e){this.currentElTop=e.y}},{key:"initMoveThreshold",value:function(e){var t=e.y;this.initialElTop=t,this.currentElTop=t}},{key:"hasPassedMoveThreshold",get:function(){return Math.abs(this.currentElTop-this.initialElTop)>this.tapMoveThreshold}},{key:"isTapGestureActive",get:function(){return!this.hasPassedMoveThreshold&&this.hasTapGestureEnded}}]),t}(a.a);t.a=c},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=n(0),a=n(3),u=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),c=function(e){function t(e){var n=e.onIsActiveChanged,r=e.hoverDelayInMs,s=e.hoverOffDelayInMs;o(this,t);var a=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,{onIsActiveChanged:n}));return a.hoverDelayInMs=r,a.hoverOffDelayInMs=s,a}return r(t,e),u(t,[{key:"mouseEntered",value:function(){this.clearTimers(),this.schedulActivation(this.hoverDelayInMs)}},{key:"mouseLeft",value:function(){this.clearTimers(),this.scheduleDeactivation(this.hoverOffDelayInMs)}},{key:"schedulActivation",value:function(e){var t=this,n=setTimeout(function(){t.activate()},e);this.timers.push({id:n,name:s.d})}},{key:"scheduleDeactivation",value:function(e){var t=this,n=setTimeout(function(){t.deactivate()},e);this.timers.push({id:n,name:s.f})}}]),t}(a.a);t.a=c},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=n(3),a=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),u=function(e){function t(e){var n=e.onIsActiveChanged;return o(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,{onIsActiveChanged:n}))}return r(t,e),a(t,[{key:"mouseClicked",value:function(){this.toggleActivation()}}]),t}(s.a);t.a=u}])});