/** * Modules in this bundle * @license * * smartphoto: * license: MIT (http://opensource.org/licenses/MIT) * author: appleple * homepage: http://developer.a-blogcms.jp * version: 0.5.9 * * a-template: * license: MIT (http://opensource.org/licenses/MIT) * author: steelydylan * maintainers: steelydylan * version: 0.2.0 * * delegate: * license: MIT (http://opensource.org/licenses/MIT) * maintainers: zenorocha * homepage: https://github.com/zenorocha/delegate#readme * version: 3.1.2 * * morphdom: * license: MIT (http://opensource.org/licenses/MIT) * author: Patrick Steele-Idem * maintainers: mlrawlings , pnidem * homepage: https://github.com/patrick-steele-idem/morphdom#readme * version: 2.3.2 * * This header is generated by licensify (https://github.com/twada/licensify) */ !function t(e,a,o){function i(s,n){if(!a[s]){if(!e[s]){var h="function"==typeof require&&require;if(!n&&h)return h(s,!0);if(r)return r(s,!0);var d=new Error("Cannot find module '"+s+"'");throw d.code="MODULE_NOT_FOUND",d}var c=a[s]={exports:{}};e[s][0].call(c.exports,function(t){var a=e[s][1][t];return i(a||t)},c,c.exports,t,e,a,o)}return a[s].exports}for(var r="function"==typeof require&&require,s=0;s>>0,o=arguments[1],i=void 0,r=0;r=0&&e.item(a)!==this;);return a>-1});var c=function(t){return document.querySelector(t)},l=function(t){for(var e=0,a=n.length;e1;)a=a[o.shift()];a[o.shift()]=e}},{key:"removeDataByString",value:function(t){for(var e=this.data,a=t.split(".");a.length>1;)e=e[a.shift()];var o=a.shift();o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o]}},{key:"resolveBlock",value:function(t,e,a){var o=this,i=t.match(//g),r=t.match(//g),s=t.match(//g),n=t.match(//g);if(i)for(var h=0,d=i.length;h/g,function(t,e){return c("#"+e).innerHTML})}},{key:"resolveWith",value:function(t){return t=t.replace(/(([\n\r\t]|.)*?)/g,function(t,e,a){return t=t.replace(/data\-bind=['"](.*?)['"]/g,"data-bind='"+e+".$1'")})}},{key:"resolveLoop",value:function(t){var e=this;return t=t.replace(/(([\n\r\t]|.)*?)/g,function(t,a,o){var i=e.getDataByString(a),r=[];r="function"==typeof i?i.apply(e):i;var s="";if(r instanceof Array)for(var n=0,h=r.length;n(([\n\r\t]|.)*?)/g)}},{key:"getHtml",value:function(t,e){var a=this.atemplate.find(function(e){return e.id===t}),o="";if(a&&a.html&&(o=a.html),e&&(o=t),!o)return"";var i=this.data;for(o=this.resolveInclude(o),o=this.resolveWith(o);this.hasLoop(o);)o=this.resolveLoop(o);return o=this.resolveBlock(o,i),o=o.replace(/\\([^\\])/g,"$1"),o=this.resolveAbsBlock(o),o.replace(/^([\t ])*\n/gm,"")}},{key:"update",value:function(t,e){var a=(this.getHtml(),this.templates),o=t||"html";this.beforeUpdated&&this.beforeUpdated();for(var i=0,s=a.length;i"+d+""):(c(h).insertAdjacentHTML("afterend",'
'),"text"===o?c("[data-id='"+n+"']").innerText=d:c("[data-id='"+n+"']").innerHTML=d),e))break}return this.updateBindingData(e),this.onUpdated&&this.onUpdated(e),this}},{key:"updateBindingData",value:function(t){for(var e=this,a=this.templates,o=0,i=a.length;o1;)e=e[a.shift()];var o=a.shift();return o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o],this}}]),t}();e.exports=f},{delegate:3,morphdom:4}],2:[function(t,e,a){function o(t,e){for(;t&&t.nodeType!==i;){if(t.matches(e))return t;t=t.parentNode}}var i=9;if("undefined"!=typeof Element&&!Element.prototype.matches){var r=Element.prototype;r.matches=r.matchesSelector||r.mozMatchesSelector||r.msMatchesSelector||r.oMatchesSelector||r.webkitMatchesSelector}e.exports=o},{}],3:[function(t,e,a){function o(t,e,a,o,r){var s=i.apply(this,arguments);return t.addEventListener(a,s,r),{destroy:function(){t.removeEventListener(a,s,r)}}}function i(t,e,a,o){return function(a){a.delegateTarget=r(a.target,e),a.delegateTarget&&o.call(t,a)}}var r=t("./closest");e.exports=o},{"./closest":2}],4:[function(t,e,a){"use strict";function o(t){!l&&f.createRange&&(l=f.createRange(),l.selectNode(f.body));var e;return l&&l.createContextualFragment?e=l.createContextualFragment(t):(e=f.createElement("body"),e.innerHTML=t),e.childNodes[0]}function i(t,e){var a=t.nodeName,o=e.nodeName;return a===o||!!(e.actualize&&a.charCodeAt(0)<91&&o.charCodeAt(0)>90)&&a===o.toUpperCase()}function r(t,e){return e&&e!==p?f.createElementNS(e,t):f.createElement(t)}function s(t,e){for(var a=t.firstChild;a;){var o=a.nextSibling;e.appendChild(a),a=o}return e}function n(t,e){var a,o,i,r,s,n=e.attributes;for(a=n.length-1;a>=0;--a)o=n[a],i=o.name,r=o.namespaceURI,s=o.value,r?(i=o.localName||i,t.getAttributeNS(r,i)!==s&&t.setAttributeNS(r,i,s)):t.getAttribute(i)!==s&&t.setAttribute(i,s);for(n=t.attributes,a=n.length-1;a>=0;--a)o=n[a],!1!==o.specified&&(i=o.name,r=o.namespaceURI,r?(i=o.localName||i,v(e,r,i)||t.removeAttributeNS(r,i)):v(e,null,i)||t.removeAttribute(i))}function h(t,e,a){t[a]!==e[a]&&(t[a]=e[a],t[a]?t.setAttribute(a,""):t.removeAttribute(a,""))}function d(){}function c(t){return t.id}var l,u,p="http://www.w3.org/1999/xhtml",f="undefined"==typeof document?void 0:document,m=f?f.body||f.createElement("div"):{};u=m.hasAttributeNS?function(t,e,a){return t.hasAttributeNS(e,a)}:m.hasAttribute?function(t,e,a){return t.hasAttribute(a)}:function(t,e,a){return null!=t.getAttributeNode(e,a)};var v=u,g={OPTION:function(t,e){h(t,e,"selected")},INPUT:function(t,e){h(t,e,"checked"),h(t,e,"disabled"),t.value!==e.value&&(t.value=e.value),v(e,null,"value")||t.removeAttribute("value")},TEXTAREA:function(t,e){var a=e.value;t.value!==a&&(t.value=a);var o=t.firstChild;if(o){var i=o.nodeValue;if(i==a||!a&&i==t.placeholder)return;o.nodeValue=a}},SELECT:function(t,e){if(!v(e,null,"multiple")){for(var a=0,o=e.firstChild;o;){var i=o.nodeName;if(i&&"OPTION"===i.toUpperCase()){if(v(o,null,"selected")){a;break}a++}o=o.nextSibling}t.selectedIndex=a}}},x=1,y=3,P=8,E=function(t){return function(e,a,n){function h(t){w?w.push(t):w=[t]}function l(t,e){if(t.nodeType===x)for(var a=t.firstChild;a;){var o=void 0;e&&(o=_(a))?h(o):(A(a),a.firstChild&&l(a,e)),a=a.nextSibling}}function u(t,e,a){!1!==k(t)&&(e&&e.removeChild(t),A(t),l(t,a))}function p(t){if(t.nodeType===x)for(var e=t.firstChild;e;){var a=_(e);a&&(C[a]=e),p(e),e=e.nextSibling}}function m(t){S(t);for(var e=t.firstChild;e;){var a=e.nextSibling,o=_(e);if(o){var r=C[o];r&&i(e,r)&&(e.parentNode.replaceChild(r,e),v(r,e))}m(e),e=a}}function v(o,r,s){var n,d=_(r);if(d&&delete C[d],!a.isSameNode||!a.isSameNode(e)){if(!s){if(!1===N(o,r))return;if(t(o,r),I(o),!1===B(o,r))return}if("TEXTAREA"!==o.nodeName){var c,l,p,E,w=r.firstChild,S=o.firstChild;t:for(;w;){for(p=w.nextSibling,c=_(w);S;){if(l=S.nextSibling,w.isSameNode&&w.isSameNode(S)){w=p,S=l;continue t}n=_(S);var k=S.nodeType,A=void 0;if(k===w.nodeType&&(k===x?(c?c!==n&&((E=C[c])?S.nextSibling===E?A=!1:(o.insertBefore(E,S),l=S.nextSibling,n?h(n):u(S,o,!0),S=E):A=!1):n&&(A=!1),(A=!1!==A&&i(S,w))&&v(S,w)):k!==y&&k!=P||(A=!0,S.nodeValue=w.nodeValue)),A){w=p,S=l;continue t}n?h(n):u(S,o,!0),S=l}if(c&&(E=C[c])&&i(E,w))o.appendChild(E),v(E,w);else{var D=b(w);!1!==D&&(D&&(w=D),w.actualize&&(w=w.actualize(o.ownerDocument||f)),o.appendChild(w),m(w))}w=p,S=l}for(;S;)l=S.nextSibling,(n=_(S))?h(n):u(S,o,!0),S=l}var z=g[o.nodeName];z&&z(o,r)}}if(n||(n={}),"string"==typeof a)if("#document"===e.nodeName||"HTML"===e.nodeName){var E=a;a=f.createElement("html"),a.innerHTML=E}else a=o(a);var w,_=n.getNodeKey||c,b=n.onBeforeNodeAdded||d,S=n.onNodeAdded||d,N=n.onBeforeElUpdated||d,I=n.onElUpdated||d,k=n.onBeforeNodeDiscarded||d,A=n.onNodeDiscarded||d,B=n.onBeforeElChildrenUpdated||d,D=!0===n.childrenOnly,C={};p(e);var z=e,G=z.nodeType,T=a.nodeType;if(!D)if(G===x)T===x?i(e,a)||(A(e),z=s(e,r(a.nodeName,a.namespaceURI))):z=a;else if(G===y||G===P){if(T===G)return z.nodeValue=a.nodeValue,z;z=a}if(z===a)A(e);else if(v(z,a,D),w)for(var O=0,X=w.length;O"),[].forEach.call(r.elements,function(t){r.addNewItem(t)});var h=r._getCurrentItemByHash();return h&&c.triggerEvent(h.element,"click"),r.update(),r._getEachImageSize().then(function(){r._fireEvent("loadall")}),setInterval(function(){r._doAnim()},r.data.forceInterval),r.data.isSmartPhone?(window.addEventListener("orientationchange",function(){r._resetTranslate(),r._setPosByCurrentIndex(),r._setHashByCurrentIndex(),r._setSizeByScreen(),r.update()}),r.data.useOrientationApi?(window.addEventListener("deviceorientation",function(t){var e=window.orientation;t&&t.gamma&&!r.data.appearEffect&&(r.isBeingZoomed||r.photoSwipable||r.data.elastic||!r.data.scale||(0===e?r._calcGravity(t.gamma,t.beta):90===e?r._calcGravity(t.beta,t.gamma):-90===e?r._calcGravity(-t.beta,-t.gamma):180===e&&r._calcGravity(-t.gamma,-t.beta)))}),r):i(r)):(window.addEventListener("resize",function(){r._resetTranslate(),r._setPosByCurrentIndex(),r._setSizeByScreen(),r.update()}),window.addEventListener("keydown",function(t){var e=t.keyCode||t.which;!0!==r.data.hide&&(37===e?r.gotoSlide(r.data.prev):39===e?r.gotoSlide(r.data.next):27===e&&r.hidePhoto())}),i(r))}return r(e,t),s(e,[{key:"on",value:function(t,e){var a=this;this._getElementByClass(this.data.classNames.smartPhoto).addEventListener(t,function(t){e.call(a,t)})}},{key:"increment",value:function(t){return t+1}},{key:"virtualPos",value:function(t){return(t=parseInt(t,10))/this._getSelectedItem().scale/this.data.scaleSize}},{key:"groupItems",value:function(){return this.data.group[this.data.currentGroup]}},{key:"_getEachImageSize",value:function(){var t=[],e=this.data.group,a=function(e){var a=new Promise(function(t,a){var o=new Image;o.onload=function(){e.width=o.width,e.height=o.height,e.loaded=!0,t()},o.onerror=function(){a()},o.src=e.src});t.push(a)};return Object.keys(e).forEach(function(t){e[t].forEach(a)}),Promise.all(t)}},{key:"_resetTranslate",value:function(){var t=this;this.groupItems().forEach(function(e,a){e.translateX=t._getWindowWidth()*a})}},{key:"addNewItem",value:function(t){var e=this,a=t.getAttribute("data-group")||"nogroup",o=this.data.group;"nogroup"===a&&t.setAttribute("data-group","nogroup"),o[a]||(o[a]=[]);var i=o[a].length,r={src:t.getAttribute("href"),caption:t.getAttribute("data-caption"),groupId:a,translateX:this._getWindowWidth()*i,index:i,translateY:0,width:50,height:50,id:t.getAttribute("data-id")||i,loaded:!1,processed:!1,element:t};o[a].push(r),this.data.currentGroup=a,t.getAttribute("data-id")||t.setAttribute("data-id",i),t.setAttribute("data-index",i),t.addEventListener("click",function(a){a.preventDefault(),e.data.currentGroup=t.getAttribute("data-group"),e.data.currentIndex=parseInt(t.getAttribute("data-index"),10),e._setHashByCurrentIndex();var o=e._getSelectedItem();o.loaded?(e._initPhoto(),e.addAppearEffect(t),e.clicked=!0,e.update(),e._fireEvent("open")):e._loadItem(o).then(function(){e._initPhoto(),e.addAppearEffect(t),e.clicked=!0,e.update(),e._fireEvent("open")})})}},{key:"_initPhoto",value:function(){this.data.total=this.groupItems().length,this.data.hide=!1,this.data.photoPosX=0,this.data.photoPosY=0,this._setPosByCurrentIndex(),this._setSizeByScreen(),this.setArrow(),"fill"===this.data.resizeStyle&&this.data.isSmartPhone&&(this.data.scale=!0,this.data.hideUi=!0,this.data.scaleSize=this._getScaleBoarder())}},{key:"onUpdated",value:function(){var t=this;if(this.data.appearEffect&&this.data.appearEffect.once&&(this.data.appearEffect.once=!1,this.execEffect().then(function(){t.data.appearEffect=null,t.data.appear=!0,t.update()})),this.clicked){this.clicked=!1;var e=this.data.classNames;this._getElementByClass(e.smartPhotoCaption).focus()}}},{key:"execEffect",value:function(){var t=this;return new Promise(function(e){var a=t.data.appearEffect,o=t.data.classNames,i=t._getElementByClass(o.smartPhotoImgClone),r=function t(){i.removeEventListener("transitionend",t,!0),e()};i.addEventListener("transitionend",r,!0),setTimeout(function(){i.style.transform="translate("+a.afterX+"px, "+a.afterY+"px) scale("+a.scale+")"},10)})}},{key:"addAppearEffect",value:function(t){var e=t.querySelector("img"),a=c.getViewPos(e),o={},i=1;o.width=e.offsetWidth,o.height=e.offsetHeight,o.top=a.top,o.left=a.left,o.once=!0,o.img=e.getAttribute("src");var r=this._getWindowWidth(),s=this._getWindowHeight(),n=s-this.data.headerHeight-this.data.footerHeight;"fill"===this.data.resizeStyle&&this.data.isSmartPhone?i=e.offsetWidth>e.offsetHeight?s/e.offsetHeight:r/e.offsetWidth:(i=n/e.offsetHeight)*e.offsetWidth>r&&(i=r/e.offsetWidth);var h=(i-1)/2*e.offsetWidth+(r-e.offsetWidth*i)/2,d=(i-1)/2*e.offsetHeight+(s-e.offsetHeight*i)/2;o.afterX=h,o.afterY=d,o.scale=i,this.data.appearEffect=o}},{key:"hidePhoto",value:function(){var t=this;this.data.hide=!0,this.data.appear=!1,this.data.appearEffect=null,this.data.hideUi=!1,this.data.scale=!1,this.data.scaleSize=1;var e=window.scrollX,a=window.scrollY;location.hash&&this._setHash(""),window.scroll(e,a),this._doHideEffect().then(function(){t.update(),t._fireEvent("close")})}},{key:"_doHideEffect",value:function(){var t=this;return new Promise(function(e){var a=t.data.classNames,o=t._getElementByClass(a.smartPhoto),i=t._getElementByQuery(".current ."+a.smartPhotoImg),r=t._getWindowHeight(),s=function t(){o.removeEventListener("transitionend",t,!0),e()};o.style.opacity=0,i.style.transform="translateY("+r+"px)",o.addEventListener("transitionend",s,!0)})}},{key:"_getElementByClass",value:function(t){return document.querySelector('[data-id="'+this.id+'"] .'+t)}},{key:"_getElementByQuery",value:function(t){return document.querySelector('[data-id="'+this.id+'"] '+t)}},{key:"_getTouchPos",value:function(){var t=0,e=0,a="undefined"==typeof event?this.e:event;return this._isTouched(a)?(t=a.touches[0].pageX,e=a.touches[0].pageY):a.pageX&&(t=a.pageX,e=a.pageY),{x:t,y:e}}},{key:"_getGesturePos",value:function(t){var e=t.touches;return[{x:e[0].pageX,y:e[0].pageY},{x:e[1].pageX,y:e[1].pageY}]}},{key:"_setPosByCurrentIndex",value:function(){var t=this,e=this.groupItems(),a=-1*e[this.data.currentIndex].translateX;this.pos.x=a,setTimeout(function(){t.data.translateX=a,t.data.translateY=0,t._listUpdate()},1)}},{key:"_setHashByCurrentIndex",value:function(){var t=window.scrollX,e=window.scrollY,a=this.groupItems(),o=a[this.data.currentIndex].id,i=this.data.currentGroup,r="group="+i+"&photo="+o;this._setHash(r),window.scroll(t,e)}},{key:"_setHash",value:function(t){window.history&&window.history.pushState&&(t?window.history.replaceState(null,null,location.pathname+"#"+t):window.history.replaceState(null,null,""+location.pathname))}},{key:"_getCurrentItemByHash",value:function(){var t=this.data.group,e=location.hash.substr(1),a=c.parseQuery(e),o=null,i=function(t){a.group===t.groupId&&a.photo===t.id&&(o=t)};return Object.keys(t).forEach(function(e){t[e].forEach(i)}),o}},{key:"_loadItem",value:function(t){return new Promise(function(e){var a=new Image;a.onload=function(){t.width=a.width,t.height=a.height,t.loaded=!0,e()},a.onerror=function(){e()},a.src=t.src})}},{key:"_setSizeByScreen",value:function(){var t=this._getWindowWidth(),e=this._getWindowHeight(),a=this.data.headerHeight,o=this.data.footerHeight,i=e-(a+o);this.groupItems().forEach(function(a){a.loaded&&(a.processed=!0,a.scale=i/a.height,a.x=(a.scale-1)/2*a.width+(t-a.width*a.scale)/2,a.y=(a.scale-1)/2*a.height+(e-a.height*a.scale)/2,a.width*a.scale>t&&(a.scale=t/a.width,a.x=(a.scale-1)/2*a.width))})}},{key:"_slideList",value:function(){var t=this;this.data.scaleSize=1,this.isBeingZoomed=!1,this.data.hideUi=!1,this.data.scale=!1,this.data.photoPosX=0,this.data.photoPosY=0,this.data.onMoveClass=!0,this._setPosByCurrentIndex(),this._setHashByCurrentIndex(),this._setSizeByScreen(),setTimeout(function(){t.data.onMoveClass=!1,t.setArrow(),t.update(),t.data.oldIndex!==t.data.currentIndex&&t._fireEvent("change"),t.data.oldIndex=t.data.currentIndex},200)}},{key:"gotoSlide",value:function(t){this.e&&this.e.preventDefault&&this.e.preventDefault(),this.data.currentIndex=parseInt(t,10),this.data.currentIndex||(this.data.currentIndex=0),this._slideList()}},{key:"setArrow",value:function(){var t=this.groupItems(),e=t.length,a=this.data.currentIndex+1,o=this.data.currentIndex-1;this.data.showNextArrow=!1,this.data.showPrevArrow=!1,a!==e&&(this.data.next=a,this.data.showNextArrow=!0),-1!==o&&(this.data.prev=o,this.data.showPrevArrow=!0)}},{key:"beforeDrag",value:function(){if(this._isGestured(this.e))return void this.beforeGesture();if(this.isBeingZoomed=!1,this.data.scale)return void this.beforePhotoDrag();var t=this._getTouchPos();this.isSwipable=!0,this.dragStart=!0,this.firstPos=t,this.oldPos=t}},{key:"afterDrag",value:function(){var t=this.groupItems(),e=new Date,a=e.getTime(),o=this.tapSecond-a,i=0,r=0;return this.isSwipable=!1,this.onListMove=!1, this.oldPos&&(i=this.oldPos.x-this.firstPos.x,r=this.oldPos.y-this.firstPos.y),this.isBeingZoomed?void this.afterGesture():this.data.scale?void this.afterPhotoDrag():c.isSmartPhone()||0!==i||0!==r?Math.abs(o)<=500&&0===i&&0===r?(this.e.preventDefault(),void this.zoomPhoto()):(this.tapSecond=a,this._fireEvent("swipeend"),"horizontal"===this.moveDir&&(i>=this.data.swipeOffset&&0!==this.data.currentIndex?this.data.currentIndex-=1:i<=-this.data.swipeOffset&&this.data.currentIndex!==t.length-1&&(this.data.currentIndex+=1),this._slideList()),void("vertical"===this.moveDir&&(r>=this.data.swipeOffset?this.hidePhoto():(this.data.translateY=0,this._slideList())))):void this.zoomPhoto()}},{key:"onDrag",value:function(){if(this.e.preventDefault(),this._isGestured(this.e)&&!1===this.onListMove)return void this.onGesture();if(!this.isBeingZoomed){if(this.data.scale)return void this.onPhotoDrag();if(this.isSwipable){var t=this._getTouchPos(),e=t.x-this.oldPos.x,a=t.y-this.firstPos.y;this.dragStart&&(this._fireEvent("swipestart"),this.dragStart=!1,Math.abs(e)>Math.abs(a)?this.moveDir="horizontal":this.moveDir="vertical"),"horizontal"===this.moveDir?(this.pos.x+=e,this.data.translateX=this.pos.x):this.data.translateY=a,this.onListMove=!0,this.oldPos=t,this._listUpdate()}}}},{key:"zoomPhoto",value:function(){var t=this;this.data.hideUi=!0,this.data.scaleSize=this._getScaleBoarder(),this.data.photoPosX=0,this.data.photoPosY=0,this._photoUpdate(),setTimeout(function(){t.data.scale=!0,t._photoUpdate(),t._fireEvent("zoomin")},300)}},{key:"zoomOutPhoto",value:function(){this.data.scaleSize=1,this.isBeingZoomed=!1,this.data.hideUi=!1,this.data.scale=!1,this.data.photoPosX=0,this.data.photoPosY=0,this._photoUpdate(),this._fireEvent("zoomout")}},{key:"beforePhotoDrag",value:function(){var t=this._getTouchPos();this.photoSwipable=!0,this.data.photoPosX||(this.data.photoPosX=0),this.data.photoPosY||(this.data.photoPosY=0),this.oldPhotoPos=t,this.firstPhotoPos=t}},{key:"onPhotoDrag",value:function(){if(this.photoSwipable){this.e.preventDefault();var t=this._getTouchPos(),e=t.x-this.oldPhotoPos.x,a=t.y-this.oldPhotoPos.y,o=this._round(this.data.scaleSize*e,6),i=this._round(this.data.scaleSize*a,6);"number"==typeof o&&(this.data.photoPosX+=o,this.photoVX=o),"number"==typeof i&&(this.data.photoPosY+=i,this.photoVY=i),this.oldPhotoPos=t,this._photoUpdate()}}},{key:"afterPhotoDrag",value:function(){if(this.oldPhotoPos.x===this.firstPhotoPos.x&&this.photoSwipable)this.photoSwipable=!1,this.zoomOutPhoto();else{this.photoSwipable=!1;var t=this._getSelectedItem(),e=this._makeBound(t),a=this.data.swipeOffset*this.data.scaleSize,o=0,i=0;if(this.data.photoPosX>e.maxX?o=-1:this.data.photoPosXe.maxY?i=-1:this.data.photoPosYa&&0!==this.data.currentIndex)return void this.gotoSlide(this.data.prev);if(e.minX-this.data.photoPosX>a&&this.data.currentIndex+1!==this.data.total)return void this.gotoSlide(this.data.next);0===o&&0===i?(this.vx=this.photoVX/5,this.vy=this.photoVY/5):this._registerElasticForce(o,i)}}},{key:"beforeGesture",value:function(){this._fireEvent("gesturestart");var t=this._getGesturePos(this.e),e=this._getDistance(t[0],t[1]);this.isBeingZoomed=!0,this.oldDistance=e,this.data.scale=!0,this.e.preventDefault()}},{key:"onGesture",value:function(){var t=this._getGesturePos(this.e),e=this._getDistance(t[0],t[1]),a=(e-this.oldDistance)/100,o=this.data.scaleSize,i=this.data.photoPosX,r=this.data.photoPosY;this.isBeingZoomed=!0,this.data.scaleSize+=this._round(a,6),this.data.scaleSize<.2&&(this.data.scaleSize=.2),this.data.scaleSizethis._getScaleBoarder()?this.data.hideUi=!0:this.data.hideUi=!1,this.oldDistance=e,this.e.preventDefault(),this._photoUpdate()}},{key:"afterGesture",value:function(){this.data.scaleSize>this._getScaleBoarder()||(this.data.photoPosX=0,this.data.photoPosY=0,this.data.scale=!1,this.data.scaleSize=1,this.data.hideUi=!1,this._fireEvent("gestureend"),this._photoUpdate())}},{key:"_getForceAndTheta",value:function(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}},{key:"_getScaleBoarder",value:function(){var t=this._getSelectedItem(),e=this._getWindowWidth(),a=this._getWindowHeight();return c.isSmartPhone()?t.width>t.height?a/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}},{key:"_makeBound",value:function(t){var e=t.width*t.scale*this.data.scaleSize,a=t.height*t.scale*this.data.scaleSize,o=void 0,i=void 0,r=void 0,s=void 0,n=this._getWindowWidth(),h=this._getWindowHeight();return n>e?(r=(n-e)/2,o=-1*r):(r=(e-n)/2,o=-1*r),h>a?(s=(h-a)/2,i=-1*s):(s=(a-h)/2,i=-1*s),{minX:this._round(o,6)*this.data.scaleSize,minY:this._round(i,6)*this.data.scaleSize,maxX:this._round(r,6)*this.data.scaleSize,maxY:this._round(s,6)*this.data.scaleSize}}},{key:"_registerElasticForce",value:function(t,e){var a=this,o=this._getSelectedItem(),i=this._makeBound(o);this.data.elastic=!0,1===t?this.data.photoPosX=i.minX:-1===t&&(this.data.photoPosX=i.maxX),1===e?this.data.photoPosY=i.minY:-1===e&&(this.data.photoPosY=i.maxY),this._photoUpdate(),setTimeout(function(){a.data.elastic=!1,a._photoUpdate()},300)}},{key:"_getSelectedItem",value:function(){var t=this.data,e=t.currentIndex;return t.group[t.currentGroup][e]}},{key:"_getUniqId",value:function(){return(Date.now().toString(36)+Math.random().toString(36).substr(2,5)).toUpperCase()}},{key:"_getDistance",value:function(t,e){var a=t.x-e.x,o=t.y-e.y;return Math.sqrt(a*a+o*o)}},{key:"_round",value:function(t,e){var a=Math.pow(10,e);return t*=a,t=Math.round(t),t/=a}},{key:"_isTouched",value:function(t){return!(!t||!t.touches)}},{key:"_isGestured",value:function(t){return!!(t&&t.touches&&t.touches.length>1)}},{key:"_isSmartPhone",value:function(){var t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0}},{key:"_calcGravity",value:function(t,e){(t>5||t<-5)&&(this.vx+=.05*t),!1!==this.data.verticalGravity&&(e>5||e<-5)&&(this.vy+=.05*e)}},{key:"_photoUpdate",value:function(){var t=this.data.classNames,e=this._getElementByQuery(".current"),a=e.querySelector("."+t.smartPhotoImg),o=this._getElementByQuery("."+t.smartPhotoNav),i=this._getElementByQuery("."+t.smartPhotoArrows),r=this.virtualPos(this.data.photoPosX),s=this.virtualPos(this.data.photoPosY),n=this.data.scaleSize,h="translate("+r+"px,"+s+"px) scale("+n+")";a.style.transform=h,this.data.scale?c.addClass(a,t.smartPhotoImgOnMove):c.removeClass(a,t.smartPhotoImgOnMove),this.data.elastic?c.addClass(a,t.smartPhotoImgElasticMove):c.removeClass(a,t.smartPhotoImgElasticMove),this.data.hideUi?(o&&o.setAttribute("aria-hidden","true"),i&&i.setAttribute("aria-hidden","true")):(o&&o.setAttribute("aria-hidden","false"),i&&i.setAttribute("aria-hidden","false"))}},{key:"_getWindowWidth",value:function(){return document.documentElement.clientWidth}},{key:"_getWindowHeight",value:function(){return window.innerHeight}},{key:"_listUpdate",value:function(){var t=this.data.classNames,e=this._getElementByQuery("."+t.smartPhotoList),a="translate("+this.data.translateX+"px,"+this.data.translateY+"px)";e.style.transform=a,this.data.onMoveClass?c.addClass(e,t.smartPhotoListOnMove):c.removeClass(e,t.smartPhotoListOnMove)}},{key:"_fireEvent",value:function(t){var e=this._getElementByClass(this.data.classNames.smartPhoto);c.triggerEvent(e,t)}},{key:"_doAnim",value:function(){if(!(this.isBeingZoomed||this.isSwipable||this.photoSwipable||this.data.elastic)&&this.data.scale){this.data.photoPosX+=this.vx,this.data.photoPosY+=this.vy;var t=this._getSelectedItem(),e=this._makeBound(t);this.data.photoPosXe.maxX&&(this.data.photoPosX=e.maxX,this.vx*=-.2),this.data.photoPosYe.maxY&&(this.data.photoPosY=e.maxY,this.vy*=-.2);var a=this._getForceAndTheta(this.vx,this.vy),o=a.force,i=a.theta;o-=this.data.registance,Math.abs(o)<.5||(this.vx=Math.cos(i)*o,this.vy=Math.sin(i)*o,this._photoUpdate())}}}]),e}(h.default);e.exports=u},{"../lib/util":8,"a-template":1}],7:[function(t,e,a){"use strict";e.exports=t("./core/")},{"./core/":6}],8:[function(t,e,a){"use strict";function o(t){t=t||{};for(var e=1;e0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},e.exports.extend=o,e.exports.triggerEvent=function(t,e,a){var o=void 0;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,a)),t.dispatchEvent(o)},e.exports.parseQuery=function(t){for(var e,a,o,i=t.split("&"),r={},s=0,n=i.length;s