summaryrefslogtreecommitdiff
path: root/dist/LightBox.Navigation.min.js
blob: 63d77af3c1f85afcdbf31a8160b1e66c61ea3b9d (plain)
1
var LightBox=LightBox||{};LightBox.Navigation=function(t){function i(n){if(e[n])return e[n].exports;var a=e[n]={exports:{},id:n,loaded:!1};return t[n].call(a.exports,a,a.exports,i),a.loaded=!0,a.exports}var e={};return i.m=t,i.c=e,i.p="",i(0)}([function(t,i){"use strict";function e(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}var n=function(){function t(t,i){for(var e=0;e<i.length;e++){var n=i[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(i,e,n){return e&&t(i.prototype,e),n&&t(i,n),i}}();Object.defineProperty(i,"__esModule",{value:!0});var a=function(){function t(){e(this,t)}return n(t,[{key:"register",value:function(t){this.lightbox=t,t.addOnStartListener(this.showNavigation.bind(this)),t.addOnEndListener(this.hideNavigation.bind(this)),t.addOnLoadEndListener(this.updateNavigation.bind(this))}},{key:"showNavigation",value:function(){var t=this;this.sink=document.createElement("div"),this.sink.id="imagelightbox-nav-sink",this.nav=document.createElement("div"),this.nav.id="imagelightbox-nav",this.sink.appendChild(this.nav),Array.prototype.forEach.call(this.lightbox.targets,function(i){t.nav.appendChild(document.createElement("a"))}),document.body.appendChild(this.sink);var i=this.nav.querySelectorAll("a");Array.prototype.forEach.call(i,function(i,e){["click","touchend"].forEach(function(n){i.addEventListener(n,t.navClick.bind(t,e))})});var e=this.nav.getBoundingClientRect(),n=e.width/2;this.nav.style.marginLeft="-"+n+"px"}},{key:"updateNavigation",value:function(){Array.prototype.forEach.call(this.nav.childNodes,function(t){t.classList.remove("active")});var t=Array.prototype.indexOf.call(this.lightbox.targets,this.lightbox.target);this.nav.childNodes[t].classList.add("active")}},{key:"hideNavigation",value:function(){try{document.body.removeChild(this.sink)}catch(t){}}},{key:"navClick",value:function(t,i){i.stopPropagation(),i.cancelBubble=!0,this.lightbox.switchToIndex(t)}}]),t}();i["default"]=a,t.exports=i["default"]}]);