1 | "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var Utils=function(){function a(){_classCallCheck(this,a)}return _createClass(a,null,[{key:"actionButton",value:function(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"click";a&&a.addEventListener(c,function(){"function"==typeof b&&b()})}},{key:"displayToggle",value:function(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",c=a.parentNode||a,d=b;if(""!==b){var e=c.style.display||"block";d="block"===e?"none":""}c.style.display=d}},{key:"existFields",value:function(a,b){var c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",d=b.split("."),e=a;return function(){return d.every(function(a){var b="undefined"!=typeof e[a];return e=e[a],b})}()?e:c}},{key:"getElementDom",value:function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",b=null;return a&&(b=document.querySelector(a)||b),b}},{key:"moveToScroll",value:function(a,b){var c=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],d=b;c?d.scrollLeft+=a:d.scrollLeft=a}},{key:"getCallbacksConfig",value:function(a){var b={callback:function(){},next:!1,previus:!1},c=a.reduce(function(a,c){var d="Slide"+(c.slide-1),e={},f=Object.assign({},b);return Object.assign(f,c),e[d]=f,Object.assign(a,e)},{});return c}},{key:"getDirecctionSlide",value:function(a){var b=a.endX-a.min_x>a.startX,c=a.endX+a.min_x<a.startX,d=a.endY<a.startY+a.max_y,e=a.startY>a.endY-a.max_y,f=a.endY-a.min_y>a.startY,g=a.endY+a.min_y<a.startY,h=a.endX<a.startX+a.max_x,i=a.startX>a.endX-a.max_x,j="";return(b||c)&&d&&e?j=a.endX>a.startX?"right":"left":(f||g)&&h&&i&&(j=a.endY>a.startY?"bottom":"top"),j}},{key:"isMobile",get:function(){var a="undefined"==typeof navigator?"desktop":navigator.userAgent.match(/iPhone|iPad|iPod|Android/i),b="undefined"==typeof window?"1024":window.innerWidth,c="desktop";return null!=a&&(768>=b?c="phone":768<b&&1024>=b&&(c="tablet")),c}}]),a}();exports.default=Utils; |