/* touchSideSwipe v0.3.1 * https://github.com/Lucyway/touch-sideswipe * 2018 (c) Mititelu Nick (aka freetitelu). MIT license. */ (function(t,e){"use strict";"function"==typeof define&&define.amd?define(e):"object"==typeof module&&module.exports?module.exports=e():t.TouchSideSwipe=e()})(this,function(){var t=function(t){"use strict";function e(){k=!0,v=document.getElementById(M.elInitID),x=document.createElement("div"),W=document.createElement("div"),g=document.createElement("div"),g.innerHTML='
',b=document.createElement("div"),x.appendChild(W),W.appendChild(g),v.parentNode.insertBefore(x,v),W.appendChild(v),document.body.insertBefore(b,document.body.lastChild),x.classList="tss",W.classList="tss-wrap",g.classList="tss-label",b.classList="tss-bg",L=E>499?M.elSubmainWidth:E*M.elSubmainMaxWidth,W.style.width=L+"px",S=L+M.sideHookWidth,x.style.transitionDuration=M.moveSpeed+"s",b.style.transitionDuration=M.moveSpeed+"s",l()}function n(){f===!0&&l(),E=window.innerWidth,L=E>499?M.elSubmainWidth:E*M.elSubmainMaxWidth,S=L+M.sideHookWidth,W.style.width=L+"px",x.style.transform="translateX("+-L+"px)",x.style.width=S+"px"}function i(t){document.body.style.overflow="hidden",x.style.transitionDuration="0s",b.style.transitionDuration="0s",b.style.zIndex=999,y=x.getBoundingClientRect().left,m=t.changedTouches[0].clientX}function s(t){w=t.changedTouches[0].clientX;var e=w-(m-y);if(e<=0){m>L&&(e+=m-L),w<=L&&(x.style.transform="translateX("+e+"px)");var n=w/L;n>0&&n<1&&(n>=M.opacityBackground?b.style.opacity=M.opacityBackground:b.style.opacity=n)}}function o(t){var e=t.changedTouches[0].clientX;document.body.style.overflow="",x.style.transitionDuration=M.moveSpeed+"s",b.style.transitionDuration=M.moveSpeed+"s",!f&&e>m?Math.abs(m-e)>M.shiftForStart?r():l():!f&&eL&&eM.shiftForStart?l():r())}function d(t){t.stopPropagation(),f===!1?r():l()}function a(t){t.stopPropagation();var e=x.getBoundingClientRect().left;t.clientX>e+L&&l()}function r(){b.style.opacity=M.opacityBackground,x.style.width=E+"px",x.style.transform="translateX(0px)",x.classList.remove("tss--close"),x.classList.add("tss--open"),b.classList.remove("tss-bg--close"),b.classList.add("tss-bg--open"),b.style.zIndex="999",f=!0}function l(){document.body.style.overflow="",b.style.opacity=0,x.style.width=S+"px",x.style.transform="translateX("+-L+"px)",x.classList.remove("tss--open"),x.classList.add("tss--close"),b.classList.remove("tss-bg--open"),b.classList.add("tss-bg--close"),b.style.zIndex="-999",f=!1}function c(){void 0!=(x&&b)&&(x.parentNode.insertBefore(v,x),x.remove(),b.remove(),k=!1)}function u(t){E=window.innerWidth,E=M.windowMaxWidth&&k&&c()}function h(){EM.windowMaxWidth){var t="(touch-sideswipe) cant use when window inner width > "+M.windowMaxWidth+"px (your actual option windowMaxWidth). Please, add the condition here.";B=function(){console.log("tssOpen "+t)},D=function(){console.log("tssClose "+t)}}else B=r,D=l}var m,w,f,y,v,x,W,g,b,L,S,M={elInitID:t.elementID||"touchSideSwipe",elSubmainWidth:t.elementWidth||400,elSubmainMaxWidth:t.elementMaxWidth||.8,sideHookWidth:t.sideHookWidth||44,moveSpeed:t.moveSpeed||.2,opacityBackground:t.opacityBackground||.8,shiftForStart:t.shiftForStart||50,windowMaxWidth:t.windowMaxWidth||1024},E=window.innerWidth,k=!1;h();var B,D;return p(),window.addEventListener("resize",p,!1),{tssOpen:B,tssClose:D}};return t});