/** * Modules in this bundle * @license * * smartphoto: * license: MIT (http://opensource.org/licenses/MIT) * author: appleple * homepage: http://developer.a-blogcms.jp * version: 1.3.6 * * a-template: * license: MIT (http://opensource.org/licenses/MIT) * author: steelydylan * version: 0.5.4 * * custom-event-polyfill: * license: MIT (http://opensource.org/licenses/MIT) * contributors: Frank Panetta, Mikhail Reenko , Joscha Feth * homepage: https://github.com/krambuhl/custom-event-polyfill#readme * version: 0.3.0 * * es6-promise-polyfill: * license: MIT (http://opensource.org/licenses/MIT) * author: Roman Dvornov * homepage: https://github.com/lahmatiy/es6-promise-polyfill#readme * version: 1.2.0 * * ie-array-find-polyfill: * license: MIT (http://opensource.org/licenses/MIT) * author: Carlos Abdalla * homepage: https://github.com/abdalla/ie-array-find-polyfill#readme * version: 1.1.0 * * morphdom: * license: MIT (http://opensource.org/licenses/MIT) * author: Patrick Steele-Idem * homepage: https://github.com/patrick-steele-idem/morphdom#readme * version: 2.3.3 * * process: * license: MIT (http://opensource.org/licenses/MIT) * author: Roman Shtylman * homepage: https://github.com/shtylman/node-process#readme * version: 0.11.10 * * timers-browserify: * licenses: MIT (http://opensource.org/licenses/MIT) * author: J. Ryan Stinnett * contributors: Guy Bedford , Ionut-Cristian Florescu , James Halliday , Jan Schär , Johannes Ewald , Jonathan Prins , Matt Esch * homepage: https://github.com/jryans/timers-browserify * version: 1.4.2 * * This header is generated by licensify (https://github.com/twada/licensify) */ !function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.SmartPhoto=t()}}(function(){var t;return function(){function t(e,a,o){function i(r,s){if(!a[r]){if(!e[r]){var d="function"==typeof require&&require;if(!s&&d)return d(r,!0);if(n)return n(r,!0);var c=new Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}var u=a[r]={exports:{}};e[r][0].call(u.exports,function(t){return i(e[r][1][t]||t)},u,u.exports,t,e,a,o)}return a[r].exports}for(var n="function"==typeof require&&require,r=0;r1;)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),n=t.match(//g),r=t.match(//g),s=t.match(//g);if(i)for(var d=0,c=i.length;d/g;return t=t.replace(e,function(t,e){return(0,d.selector)("#"+e).innerHTML})}},{key:"resolveWith",value:function(t){var e=/(([\n\r\t]|.)*?)/g;return t=t.replace(e,function(t,e){return t=t.replace(/data\-bind=['"](.*?)['"]/g,"data-bind='"+e+".$1'")})}},{key:"resolveLoop",value:function(t){var e=/(([\n\r\t]|.)*?)/g,a=this;return t=t.replace(e,function(t,e,o){var i=a.getDataByString(e),n=[];n="function"==typeof i?i.apply(a):i;var r="";if(n instanceof Array)for(var s=0,d=n.length;s(([\n\r\t]|.)*?)/g;return!!t.match(e)}},{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(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"html",a=arguments[1],o=this.templates;this.beforeUpdated&&this.beforeUpdated();for(var i=0,n=o.length;i"+u+"");else(0,d.selector)(c).insertAdjacentHTML("afterend",'
'),"text"===e?(0,d.selector)("[data-id='"+r+"']").innerText=u:(0,d.selector)("[data-id='"+r+"']").innerHTML=u;var p=t.atemplate.find(function(t){return t.id===r});p.binded||(p.binded=!0,t.addDataBind((0,d.selector)("[data-id='"+r+"']")),t.addActionBind((0,d.selector)("[data-id='"+r+"']")))}(i);return this.updateBindingData(a),this.onUpdated&&this.onUpdated(a),this}},{key:"updateBindingData",value:function(t){for(var e=this,a=this.templates,o=0,i=a.length;o1?a-1:0),i=1;i1;)e=e[a.shift()];var o=a.shift();return o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o],this}}]),t}();a.default=h,e.exports=a.default},{"./util":2,"ie-array-find-polyfill":5,morphdom:6}],2:[function(t,e,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var o=a.matches=function(t,e){for(var a=(t.document||t.ownerDocument).querySelectorAll(e),o=a.length;--o>=0&&a.item(o)!==t;);return o>-1},i=(a.selector=function(t){return document.querySelector(t)},a.findAncestor=function(t,e){if("function"==typeof t.closest)return t.closest(e)||null;for(;t&&t!==document;){if(o(t,e))return t;t=t.parentElement}return null});a.on=function(t,e,a,o){a.split(" ").forEach(function(a){t.addEventListener(a,function(t){var a=(t.target,i(t.target,e));a&&(t.delegateTarget=a,o(t))})})}},{}],3:[function(t,e,a){try{var o=new window.CustomEvent("test");if(o.preventDefault(),!0!==o.defaultPrevented)throw new Error("Could not prevent default")}catch(t){var i=function(t,e){var a,o;return e=e||{bubbles:!1,cancelable:!1,detail:void 0},a=document.createEvent("CustomEvent"),a.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),o=a.preventDefault,a.preventDefault=function(){o.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(t){this.defaultPrevented=!0}},a};i.prototype=window.Event.prototype,window.CustomEvent=i}},{}],4:[function(e,a,o){(function(e,a){!function(e){function i(t){return"[object Array]"===Object.prototype.toString.call(t)}function n(){for(var t=0;t>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var o=arguments[1],i=0;i90)&&a===o.toUpperCase()}function n(t,e){return e&&e!==f?p.createElementNS(e,t):p.createElement(t)}function r(t,e){for(var a=t.firstChild;a;){var o=a.nextSibling;e.appendChild(a),a=o}return e}function s(t,e){var a,o,i,n,r,s=e.attributes;for(a=s.length-1;a>=0;--a)o=s[a],i=o.name,n=o.namespaceURI,r=o.value,n?(i=o.localName||i,t.getAttributeNS(n,i)!==r&&t.setAttributeNS(n,i,r)):t.getAttribute(i)!==r&&t.setAttribute(i,r);for(s=t.attributes,a=s.length-1;a>=0;--a)o=s[a],!1!==o.specified&&(i=o.name,n=o.namespaceURI,n?(i=o.localName||i,v(e,n,i)||t.removeAttributeNS(n,i)):v(e,null,i)||t.removeAttribute(i))}function d(t,e,a){t[a]!==e[a]&&(t[a]=e[a],t[a]?t.setAttribute(a,""):t.removeAttribute(a,""))}function c(){}function u(t){return t.id}var h,l,f="http://www.w3.org/1999/xhtml",p="undefined"==typeof document?void 0:document,m=p?p.body||p.createElement("div"):{};l=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=l,g={OPTION:function(t,e){d(t,e,"selected")},INPUT:function(t,e){d(t,e,"checked"),d(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}}},y=1,x=3,w=8,P=function(t){return function(e,a,s){function d(t){E?E.push(t):E=[t]}function h(t,e){if(t.nodeType===y)for(var a=t.firstChild;a;){var o=void 0;e&&(o=b(a))?d(o):(B(a),a.firstChild&&h(a,e)),a=a.nextSibling}}function l(t,e,a){!1!==k(t)&&(e&&e.removeChild(t),B(t),h(t,a))}function f(t){if(t.nodeType===y)for(var e=t.firstChild;e;){var a=b(e);a&&(T[a]=e),f(e),e=e.nextSibling}}function m(t){I(t);for(var e=t.firstChild;e;){var a=e.nextSibling,o=b(e);if(o){var n=T[o];n&&i(e,n)&&(e.parentNode.replaceChild(n,e),v(n,e))}m(e),e=a}}function v(o,n,r){var s,c=b(n);if(c&&delete T[c],!a.isSameNode||!a.isSameNode(e)){if(!r){if(!1===N(o,n))return;if(t(o,n),S(o),!1===D(o,n))return}if("TEXTAREA"!==o.nodeName){var u,h,f,P,E=n.firstChild,I=o.firstChild;t:for(;E;){for(f=E.nextSibling,u=b(E);I;){if(h=I.nextSibling,E.isSameNode&&E.isSameNode(I)){E=f,I=h;continue t}s=b(I);var k=I.nodeType,B=void 0;if(k===E.nodeType&&(k===y?(u?u!==s&&((P=T[u])?I.nextSibling===P?B=!1:(o.insertBefore(P,I),h=I.nextSibling,s?d(s):l(I,o,!0),I=P):B=!1):s&&(B=!1),(B=!1!==B&&i(I,E))&&v(I,E)):k!==x&&k!=w||(B=!0,I.nodeValue!==E.nodeValue&&(I.nodeValue=E.nodeValue))),B){E=f,I=h;continue t}s?d(s):l(I,o,!0),I=h}if(u&&(P=T[u])&&i(P,E))o.appendChild(P),v(P,E);else{var A=_(E);!1!==A&&(A&&(E=A),E.actualize&&(E=E.actualize(o.ownerDocument||p)),o.appendChild(E),m(E))}E=f,I=h}for(;I;)h=I.nextSibling,(s=b(I))?d(s):l(I,o,!0),I=h}var O=g[o.nodeName];O&&O(o,n)}}if(s||(s={}),"string"==typeof a)if("#document"===e.nodeName||"HTML"===e.nodeName){var P=a;a=p.createElement("html"),a.innerHTML=P}else a=o(a);var E,b=s.getNodeKey||u,_=s.onBeforeNodeAdded||c,I=s.onNodeAdded||c,N=s.onBeforeElUpdated||c,S=s.onElUpdated||c,k=s.onBeforeNodeDiscarded||c,B=s.onNodeDiscarded||c,D=s.onBeforeElChildrenUpdated||c,A=!0===s.childrenOnly,T={};f(e);var O=e,C=O.nodeType,G=a.nodeType;if(!A)if(C===y)G===y?i(e,a)||(B(e),O=r(e,n(a.nodeName,a.namespaceURI))):O=a;else if(C===x||C===w){if(G===C)return O.nodeValue!==a.nodeValue&&(O.nodeValue=a.nodeValue),O;O=a}if(O===a)B(e);else if(v(O,a,A),E)for(var L=0,X=E.length;L1)for(var a=1;a=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},a.setImmediate="function"==typeof e?e:function(t){var e=c++,o=!(arguments.length<2)&&s.call(arguments,1);return d[e]=!0,n(function(){d[e]&&(o?t.apply(null,o):t.call(null),a.clearImmediate(e))}),e},a.clearImmediate="function"==typeof o?o:function(t){delete d[t]}}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":7,timers:8}],9:[function(t,e,a){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(a,"__esModule",{value:!0});var r=function(){function t(t,e){for(var a=0;a"),[].forEach.call(n.elements,function(t){n.addNewItem(t)}),n.update();var d=n._getCurrentItemByHash();return d&&u.triggerEvent(d.element,"click"),setInterval(function(){n._doAnim()},n.data.forceInterval),n.data.isSmartPhone?(window.addEventListener("orientationchange",function(){n.groupItems()&&(n._resetTranslate(),n._setPosByCurrentIndex(),n._setHashByCurrentIndex(),n._setSizeByScreen(),n.update())}),n.data.useOrientationApi?(window.addEventListener("deviceorientation",function(t){var e=window,a=e.orientation;t&&t.gamma&&!n.data.appearEffect&&(n.isBeingZoomed||n.photoSwipable||n.data.elastic||!n.data.scale||(0===a?n._calcGravity(t.gamma,t.beta):90===a?n._calcGravity(t.beta,t.gamma):-90===a?n._calcGravity(-t.beta,-t.gamma):180===a&&n._calcGravity(-t.gamma,-t.beta)))}),n):i(n)):(window.addEventListener("resize",function(){n.groupItems()&&(n._resetTranslate(),n._setPosByCurrentIndex(),n._setSizeByScreen(),n.update())}),window.addEventListener("keydown",function(t){var e=t.keyCode||t.which;!0!==n.data.hide&&(37===e?n.gotoSlide(n.data.prev):39===e?n.gotoSlide(n.data.next):27===e&&n.hidePhoto())}),i(n))}return n(e,t),r(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:"round",value:function(t){return Math.round(t)}},{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:"_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,n=document.querySelector("body"),r=t.getAttribute("href"),s=t.querySelector("img"),d=r;s&&(d=s.currentSrc?s.currentSrc:s.src);var c={src:r,thumb:d,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(c),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,o),e.clicked=!0,e.update(),n.style.overflow="hidden",e._fireEvent("open")):e._loadItem(o).then(function(){e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),n.style.overflow="hidden",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 h(function(e){u.isOldIE()&&e();var a=t.data,o=a.appearEffect,i=a.classNames,n=t._getElementByClass(i.smartPhotoImgClone),r=function t(){n.removeEventListener("transitionend",t,!0),e()};n.addEventListener("transitionend",r,!0),setTimeout(function(){n.style.transform="translate("+o.afterX+"px, "+o.afterY+"px) scale("+o.scale+")"},10)})}},{key:"addAppearEffect",value:function(t,e){if(!1===this.data.showAnimation)return void(this.data.appear=!0);var a=t.querySelector("img"),o=u.getViewPos(a),i={},n=1;i.width=a.offsetWidth,i.height=a.offsetHeight,i.top=o.top,i.left=o.left,i.once=!0,i.img=e.src;var r=this._getWindowWidth(),s=this._getWindowHeight(),d=s-this.data.headerHeight-this.data.footerHeight;"fill"===this.data.resizeStyle&&this.data.isSmartPhone?n=a.offsetWidth>a.offsetHeight?s/a.offsetHeight:r/a.offsetWidth:(i.width>=i.height?n=e.heighti.width&&(n=e.heightr&&(n=r/i.width));var c=(n-1)/2*a.offsetWidth+(r-a.offsetWidth*n)/2,h=(n-1)/2*a.offsetHeight+(s-a.offsetHeight*n)/2;i.afterX=c,i.afterY=h,i.scale=n,this.data.appearEffect=i}},{key:"hidePhoto",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"bottom";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 a=void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,o=void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop,i=document.querySelector("body");window.location.hash&&this._setHash(""),window.scroll(a,o),this._doHideEffect(e).then(function(){t.update(),i.style.overflow="",t._fireEvent("close")})}},{key:"_doHideEffect",value:function(t){var e=this;return new h(function(a){u.isOldIE()&&a();var o=e.data.classNames,i=e._getElementByClass(o.smartPhoto),n=e._getElementByQuery(".current ."+o.smartPhotoImg),r=e._getWindowHeight(),s=function t(){i.removeEventListener("transitionend",t,!0),a()};i.style.opacity=0,"bottom"===t?n.style.transform="translateY("+r+"px)":"top"===t&&(n.style.transform="translateY(-"+r+"px)"),i.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=void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,e=void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop,a=this.groupItems(),o=a[this.data.currentIndex].id,i=this.data.currentGroup,n="group="+i+"&photo="+o;this._setHash(n),window.scroll(t,e)}},{key:"_setHash",value:function(t){window.history&&window.history.pushState&&this.data.useHistoryApi&&(t?window.history.replaceState(null,null,""+location.pathname+location.search+"#"+t):window.history.replaceState(null,null,""+location.pathname+location.search))}},{key:"_getCurrentItemByHash",value:function(){var t=this.data.group,e=location.hash.substr(1),a=u.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 h(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:"_getItemByIndex",value:function(t){var e=this.data;return e.group[e.currentGroup][t]?e.group[e.currentGroup][t]:null}},{key:"_loadNeighborItems",value:function(){for(var t=this,e=this.data.currentIndex,a=this.data.loadOffset,o=e-a,i=e+a,n=[],r=o;rt&&(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(){var e=t._getSelectedItem();t.data.onMoveClass=!1,t.setArrow(),t.update(),t.data.oldIndex!==t.data.currentIndex&&t._fireEvent("change"),t.data.oldIndex=t.data.currentIndex,t._loadNeighborItems(),e.loaded||t._loadItem(e).then(function(){t._initPhoto(),t.update()})},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,n=0;return this.isSwipable=!1,this.onListMove=!1,this.oldPos&&(i=this.oldPos.x-this.firstPos.x,n=this.oldPos.y-this.firstPos.y),this.isBeingZoomed?void this.afterGesture():this.data.scale?void this.afterPhotoDrag():u.isSmartPhone()||0!==i||0!==n?Math.abs(o)<=500&&0===i&&0===n?(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&&(this.data.swipeBottomToClose&&n>=this.data.swipeOffset?this.hidePhoto("bottom"):this.data.swipeTopToClose&&n<=-this.data.swipeOffset?this.hidePhoto("top"):(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.scaleSize<=1||(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,n=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 u.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,n=void 0,r=void 0,s=this._getWindowWidth(),d=this._getWindowHeight();return s>e?(n=(s-e)/2,o=-1*n):(n=(e-s)/2,o=-1*n),d>a?(r=(d-a)/2,i=-1*r):(r=(a-d)/2,i=-1*r),{minX:this._round(o,6)*this.data.scaleSize,minY:this._round(i,6)*this.data.scaleSize,maxX:this._round(n,6)*this.data.scaleSize,maxY:this._round(r,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),n=this.virtualPos(this.data.photoPosX),r=this.virtualPos(this.data.photoPosY),s=this.data.scaleSize,d="translate("+n+"px,"+r+"px) scale("+s+")";a.style.transform=d,this.data.scale?u.addClass(a,t.smartPhotoImgOnMove):u.removeClass(a,t.smartPhotoImgOnMove),this.data.elastic?u.addClass(a,t.smartPhotoImgElasticMove):u.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&&document.documentElement?document.documentElement.clientWidth:window&&window.innerWidth?window.innerWidth:0}},{key:"_getWindowHeight",value:function(){return document&&document.documentElement?document.documentElement.clientHeight:window&&window.innerHeight?window.innerHeight:0}},{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?u.addClass(e,t.smartPhotoListOnMove):u.removeClass(e,t.smartPhotoListOnMove)}},{key:"_fireEvent",value:function(t){var e=this._getElementByClass(this.data.classNames.smartPhoto);u.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}(d.default);a.default=f,e.exports=a.default},{"../lib/util":11,"a-template":1,"custom-event-polyfill":3,"es6-promise-polyfill":4}],10:[function(t,e,a){"use strict";e.exports=t("./core/")},{"./core/":9}],11:[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},a.extend=o,a.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)},a.parseQuery=function(t){for(var e,a,o,i=t.split("&"),n={},r=0,s=i.length;r0;)t.appendChild(a.children[0])},a.addClass=function(t,e){t.classList?t.classList.add(e):t.className+=" "+e},a.removeClass=function(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")},a.getBrowser=function(){var t=window.navigator.userAgent.toLowerCase(),e=window.navigator.appVersion.toLowerCase(),a="unknown";return-1!=t.indexOf("msie")?a=-1!=e.indexOf("msie 6.")?"ie6":-1!=e.indexOf("msie 7.")?"ie7":-1!=e.indexOf("msie 8.")?"ie8":-1!=e.indexOf("msie 9.")?"ie9":-1!=e.indexOf("msie 10.")?"ie10":"ie":-1!=t.indexOf("trident/7")?a="ie11":-1!=t.indexOf("chrome")?a="chrome":-1!=t.indexOf("safari")?a="safari":-1!=t.indexOf("opera")?a="opera":-1!=t.indexOf("firefox")&&(a="firefox"),a});a.isOldIE=function(){var t=n();return-1!==t.indexOf("ie")&&parseInt(t.replace(/[^0-9]/g,""))<=10}},{}]},{},[10])(10)});