diff --git a/dist/lightgallery.es5.js b/dist/lightgallery.es5.js index e64aa4aad..373233a5b 100644 --- a/dist/lightgallery.es5.js +++ b/dist/lightgallery.es5.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 @@ -442,11 +442,12 @@ var utils = { /** * get possible width and height from the lgSize attribute. Used for ZoomFromOrigin option */ - getSize: function (el, container, spacing, defaultLgSize) { + // @todo improive this + getSize: function (el, container, spacing, isDisabled, defaultLgSize) { if (spacing === void 0) { spacing = 0; } var LGel = $LG(el); var lgSize = LGel.attr('data-lg-size') || defaultLgSize; - if (!lgSize) { + if (!lgSize || isDisabled) { return; } var isResponsiveSizes = lgSize.split(','); @@ -976,11 +977,11 @@ var LightGallery = /** @class */ (function () { LightGallery.prototype.refreshOnResize = function () { if (this.lgOpened) { var currentGalleryItem = this.galleryItems[this.index]; - var videoInfo = currentGalleryItem.__slideVideoInfo; + var __slideVideoInfo = currentGalleryItem.__slideVideoInfo, poster = currentGalleryItem.poster; this.mediaContainerPosition = this.getMediaContainerPosition(); var _a = this.mediaContainerPosition, top_1 = _a.top, bottom = _a.bottom; - this.currentImageSize = utils.getSize(this.items[this.index], this.outer, top_1 + bottom, videoInfo && this.settings.videoMaxSize); - if (videoInfo) { + this.currentImageSize = utils.getSize(this.items[this.index], this.outer, top_1 + bottom, __slideVideoInfo && !poster, __slideVideoInfo && this.settings.videoMaxSize); + if (__slideVideoInfo) { this.resizeVideoSlide(this.index, this.currentImageSize); } if (this.zoomFromOrigin && !this.isDummyImageRemoved) { @@ -1158,9 +1159,9 @@ var LightGallery = /** @class */ (function () { if (!this.settings.allowMediaOverlap) { this.setMediaContainerPosition(top, bottom); } + var _b = this.galleryItems[index], __slideVideoInfo = _b.__slideVideoInfo, poster = _b.poster; if (this.zoomFromOrigin && element) { - this.currentImageSize = utils.getSize(element, this.outer, top + bottom, this.galleryItems[index].__slideVideoInfo && - this.settings.videoMaxSize); + this.currentImageSize = utils.getSize(element, this.outer, top + bottom, __slideVideoInfo && !poster, __slideVideoInfo && this.settings.videoMaxSize); transform = utils.getTransform(element, this.outer, top, bottom, this.currentImageSize); } if (!this.zoomFromOrigin || !transform) { @@ -1423,18 +1424,19 @@ var LightGallery = /** @class */ (function () { var imgMarkup = " " + imgContent + ""; $currentSlide.prepend(imgMarkup); }; - LightGallery.prototype.onLgObjectLoad = function ($el, index, delay, speed, dummyImageLoaded) { + LightGallery.prototype.onLgObjectLoad = function ($el, index, delay, speed, dummyImageLoaded, isFirstSlide) { var _this = this; if (dummyImageLoaded) { this.LGel.trigger(lGEvents.slideItemLoad, { index: index, delay: delay || 0, + isFirstSlide: isFirstSlide, }); } $el.find('.lg-object') .first() .on('load.lg', function () { - _this.handleLgObjectLoad($el, index, delay, speed, dummyImageLoaded); + _this.handleLgObjectLoad($el, index, delay, speed, dummyImageLoaded, isFirstSlide); }); setTimeout(function () { $el.find('.lg-object') @@ -1445,7 +1447,7 @@ var LightGallery = /** @class */ (function () { }); }, speed); }; - LightGallery.prototype.handleLgObjectLoad = function ($el, index, delay, speed, dummyImageLoaded) { + LightGallery.prototype.handleLgObjectLoad = function ($el, index, delay, speed, dummyImageLoaded, isFirstSlide) { var _this = this; setTimeout(function () { $el.addClass('lg-complete lg-complete_'); @@ -1453,6 +1455,7 @@ var LightGallery = /** @class */ (function () { _this.LGel.trigger(lGEvents.slideItemLoad, { index: index, delay: delay || 0, + isFirstSlide: isFirstSlide, }); } }, speed); @@ -1479,7 +1482,7 @@ var LightGallery = /** @class */ (function () { return; } } - var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)/i); + var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)([\&|?][\S]*)*/i); var vimeo = src.match(/\/\/(?:www\.)?(?:player\.)?vimeo.com\/(?:video\/)?([0-9a-z\-_]+)/i); var wistia = src.match(/https?:\/\/(.+)?(wistia\.com|wi\.st)\/(medias|embed)\/([0-9a-z\-_]+)(.*)/); if (youtube) { @@ -1526,10 +1529,21 @@ var LightGallery = /** @class */ (function () { var videoInfo = currentGalleryItem.__slideVideoInfo; var lgVideoStyle = ''; var iframe = !!currentGalleryItem.iframe; + var isFirstSlide = !this.lGalleryOn; + // delay for adding complete class. it is 0 except first time. + var delay = 0; + if (isFirstSlide) { + if (this.zoomFromOrigin && this.currentImageSize) { + delay = this.settings.startAnimationDuration + 10; + } + else { + delay = this.settings.backdropDuration + 10; + } + } if (!$currentSlide.hasClass('lg-loaded')) { if (videoInfo) { var _a = this.mediaContainerPosition, top_2 = _a.top, bottom = _a.bottom; - var videoSize = utils.getSize(this.items[index], this.outer, top_2 + bottom, videoInfo && this.settings.videoMaxSize); + var videoSize = utils.getSize(this.items[index], this.outer, top_2 + bottom, false, videoInfo && this.settings.videoMaxSize); lgVideoStyle = this.getVideoContStyle(videoSize); } if (iframe) { @@ -1538,8 +1552,7 @@ var LightGallery = /** @class */ (function () { } else if (poster) { var dummyImg = ''; - var isFirstSlide_1 = !this.lGalleryOn; - var hasStartAnimation = !this.lGalleryOn && + var hasStartAnimation = isFirstSlide && this.zoomFromOrigin && this.currentImageSize; if (hasStartAnimation) { @@ -1547,28 +1560,10 @@ var LightGallery = /** @class */ (function () { } var markup = utils.getVideoPosterMarkup(poster, dummyImg || '', lgVideoStyle, videoInfo); $currentSlide.prepend(markup); - var delay_1 = (hasStartAnimation - ? this.settings.startAnimationDuration - : this.settings.backdropDuration) + 100; - setTimeout(function () { - _this.LGel.trigger(lGEvents.hasVideo, { - index: index, - src: src, - html5Video: _html5Video, - hasPoster: true, - isFirstSlide: isFirstSlide_1, - }); - }, delay_1); } else if (videoInfo) { var markup = "
"; $currentSlide.prepend(markup); - this.LGel.trigger(lGEvents.hasVideo, { - index: index, - src: src, - html5Video: _html5Video, - hasPoster: false, - }); } else { this.setImgMarkup(src, $currentSlide, index); @@ -1577,6 +1572,15 @@ var LightGallery = /** @class */ (function () { this.initPictureFill($img); } } + if (poster || videoInfo) { + this.LGel.trigger(lGEvents.hasVideo, { + index: index, + src: src, + html5Video: _html5Video, + hasPoster: !!poster, + isFirstSlide: isFirstSlide, + }); + } this.LGel.trigger(lGEvents.afterAppendSlide, { index: index }); if (this.lGalleryOn && this.settings.appendSubHtmlTo === '.lg-item') { @@ -1585,16 +1589,6 @@ var LightGallery = /** @class */ (function () { } // For first time add some delay for displaying the start animation. var _speed = 0; - // delay for adding complete class. it is 0 except first time. - var delay = 0; - if (!this.lGalleryOn) { - if (this.zoomFromOrigin && this.currentImageSize) { - delay = this.settings.startAnimationDuration + 10; - } - else { - delay = this.settings.backdropDuration + 10; - } - } // Do not change the delay value because it is required for zoom plugin. // If gallery opened from direct url (hash) speed value should be 0 if (delay && !$LG(document.body).hasClass('lg-from-hash')) { @@ -1616,7 +1610,7 @@ var LightGallery = /** @class */ (function () { var $img = $currentSlide.find('.lg-object'); _this.initPictureFill($img); } - _this.onLgObjectLoad($currentSlide, index, delay, _speed, true); + _this.onLgObjectLoad($currentSlide, index, delay, _speed, true, true); var mediaObject = $currentSlide .find('.lg-object') .first(); @@ -1633,7 +1627,7 @@ var LightGallery = /** @class */ (function () { } // SLide content has been added to dom $currentSlide.addClass('lg-loaded'); - this.onLgObjectLoad($currentSlide, index, delay, _speed, false); + this.onLgObjectLoad($currentSlide, index, delay, _speed, false, isFirstSlide); // @todo check load state for html5 videos if (videoInfo && videoInfo.html5 && !poster) { $currentSlide.addClass('lg-complete lg-complete_'); @@ -1834,7 +1828,7 @@ var LightGallery = /** @class */ (function () { this.setDownloadValue(index); if (videoInfo) { var _a = this.mediaContainerPosition, top_3 = _a.top, bottom = _a.bottom; - var videoSize = utils.getSize(this.items[index], this.outer, top_3 + bottom, videoInfo && this.settings.videoMaxSize); + var videoSize = utils.getSize(this.items[index], this.outer, top_3 + bottom, false, videoInfo && this.settings.videoMaxSize); this.resizeVideoSlide(index, videoSize); } this.LGel.trigger(lGEvents.beforeSlide, { @@ -2440,8 +2434,8 @@ var LightGallery = /** @class */ (function () { var transform; if (this.zoomFromOrigin && currentItem) { var _a = this.mediaContainerPosition, top_4 = _a.top, bottom = _a.bottom; - var imageSize = utils.getSize(currentItem, this.outer, top_4 + bottom, this.galleryItems[this.index].__slideVideoInfo && - this.settings.videoMaxSize); + var _b = this.galleryItems[this.index], __slideVideoInfo = _b.__slideVideoInfo, poster = _b.poster; + var imageSize = utils.getSize(currentItem, this.outer, top_4 + bottom, __slideVideoInfo && !poster, __slideVideoInfo && poster && this.settings.videoMaxSize); transform = utils.getTransform(currentItem, this.outer, top_4, bottom, imageSize); } if (this.zoomFromOrigin && transform) { diff --git a/dist/lightgallery.min.js b/dist/lightgallery.min.js index d2928d760..064c5dcb2 100644 --- a/dist/lightgallery.min.js +++ b/dist/lightgallery.min.js @@ -1,8 +1,8 @@ /** - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).lightGallery=e()}(this,(function(){"use strict";var t=function(){return(t=Object.assign||function(t){for(var e,i=1,s=arguments.length;il){o=g;break}a===r.length-1&&(o=g)}var d=o.split("-"),h=parseInt(d[0],10),c=parseInt(d[1],10),u=e.width(),m=e.height()-s,p=Math.min(u,h),f=Math.min(m,c),v=Math.min(p/h,f/c);return{width:h*v,height:c*v}}},r=function(t,e,s,n,o){if(o){var r=i(t).find("img").first();if(r.get()){var l=e.get().getBoundingClientRect(),a=l.width,g=e.height()-(s+n),d=r.width(),h=r.height(),c=r.style(),u=(a-d)/2-r.offset().left+(parseFloat(c.paddingLeft)||0)+(parseFloat(c.borderLeft)||0)+i(window).scrollLeft()+l.left,m=(g-h)/2-r.offset().top+(parseFloat(c.paddingTop)||0)+(parseFloat(c.borderTop)||0)+i(window).scrollTop()+s;return"translate3d("+(u*=-1)+"px, "+(m*=-1)+"px, 0) scale3d("+d/o.width+", "+h/o.height+", 1)"}}},l=function(t,e,i,s){return'
\n \n
'},a=function(t,e,i,s,n,o){var r="',l="";o&&(l=("string"==typeof o?JSON.parse(o):o).map((function(t){var e="";return Object.keys(t).forEach((function(i){e+=" "+i+'="'+t[i]+'"'})),""})));return""+l+r},g=function(t){for(var e=[],i=[],s="",n=0;nr){s=i[l];break}return s},d=function(t){return!!t&&(!!t.complete&&0!==t.naturalWidth)},h=function(t,e,i,s){return'
\n
\n \n Play video\n \n \n \n \n \n \n \n
\n '+(e||"")+'\n \n
'},c=function(t,e,o,r){var l=[],a=function(){for(var t=0,e=0,i=arguments.length;e-1&&(h=d),h&&(e[h]=g.value)}}var c=i(t),u=c.find("img").first().attr("alt"),m=c.attr("title"),p=r?c.attr(r):c.find("img").first().attr("src");e.thumb=p,o&&!e.subHtml&&(e.subHtml=m||u||""),e.alt=u||m||"",l.push(e)})),l},u=function(){return/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)},m={mode:"lg-slide",easing:"ease",speed:400,licenseKey:"0000-0000-000-0000",height:"100%",width:"100%",addClass:"",startClass:"lg-start-zoom",backdropDuration:300,container:document.body,startAnimationDuration:400,zoomFromOrigin:!0,hideBarsDelay:0,showBarsAfter:1e4,slideDelay:0,supportLegacyBrowser:!0,allowMediaOverlap:!1,videoMaxSize:"1280-720",defaultCaptionHeight:0,ariaLabelledby:"",ariaDescribedby:"",closable:!0,swipeToClose:!0,closeOnTap:!0,showCloseIcon:!0,showMaximizeIcon:!1,loop:!0,escKey:!0,keyPress:!0,controls:!0,slideEndAnimation:!0,hideControlOnEnd:!1,mousewheel:!1,getCaptionFromTitleOrAlt:!0,appendSubHtmlTo:".lg-sub-html",subHtmlSelectorRelative:!1,preload:2,numberOfSlideItemsInDom:10,showAfterLoad:!0,selector:"",selectWithin:"",nextHtml:"",prevHtml:"",index:0,iframeWidth:"100%",iframeHeight:"100%",download:!0,counter:!0,appendCounterTo:".lg-toolbar",swipeThreshold:50,enableSwipe:!0,enableDrag:!0,dynamic:!1,dynamicEl:[],extraProps:[],exThumbImage:"",isMobile:void 0,mobileSettings:{controls:!1,showCloseIcon:!1,download:!1},plugins:[]},p="lgAfterAppendSlide",f="lgInit",v="lgHasVideo",y="lgContainerResize",b="lgUpdateSlides",C="lgAfterAppendSubHtml",I="lgBeforeOpen",w="lgAfterOpen",x="lgSlideItemLoad",S="lgBeforeSlide",T="lgAfterSlide",E="lgPosterClick",O="lgDragStart",L="lgDragMove",D="lgDragEnd",z="lgBeforeNextSlide",G="lgBeforePrevSlide",M="lgBeforeClose",k="lgAfterClose",A=0,B=function(){function s(t,e){if(this.lgOpened=!1,this.index=0,this.plugins=[],this.lGalleryOn=!1,this.lgBusy=!1,this.currentItemsInDom=[],this.prevScrollTop=0,this.isDummyImageRemoved=!1,this.dragOrSwipeEnabled=!1,this.mediaContainerPosition={top:0,bottom:0},!t)return this;if(A++,this.lgId=A,this.el=t,this.LGel=i(t),this.generateSettings(e),this.buildModules(),this.settings.dynamic&&void 0!==this.settings.dynamicEl&&!Array.isArray(this.settings.dynamicEl))throw"When using dynamic mode, you must also define dynamicEl as an Array.";return this.galleryItems=this.getItems(),this.normalizeSettings(),this.init(),this.validateLicense(),this}return s.prototype.generateSettings=function(e){if(this.settings=t(t({},m),e),this.settings.isMobile&&"function"==typeof this.settings.isMobile?this.settings.isMobile():u()){var i=t(t({},this.settings.mobileSettings),this.settings.mobileSettings);this.settings=t(t({},this.settings),i)}},s.prototype.normalizeSettings=function(){this.settings.slideEndAnimation&&(this.settings.hideControlOnEnd=!1),this.settings.closable||(this.settings.swipeToClose=!1),this.zoomFromOrigin=this.settings.zoomFromOrigin,this.settings.dynamic&&(this.zoomFromOrigin=!1),this.settings.container||(this.settings.container=document.body),this.settings.preload=Math.min(this.settings.preload,this.galleryItems.length)},s.prototype.init=function(){var t=this;this.addSlideVideoInfo(this.galleryItems),this.buildStructure(),this.LGel.trigger(f,{instance:this}),this.settings.keyPress&&this.keyPress(),setTimeout((function(){t.enableDrag(),t.enableSwipe(),t.triggerPosterClick()}),50),this.arrow(),this.settings.mousewheel&&this.mousewheel(),this.settings.dynamic||this.openGalleryOnItemClick()},s.prototype.openGalleryOnItemClick=function(){for(var t=this,s=function(s){var o=n.items[s],r=i(o),l=e.generateUUID();r.attr("data-lg-id",l).on("click.lgcustom-item-"+l,(function(e){e.preventDefault();var i=t.settings.index||s;t.openGallery(i,o)}))},n=this,o=0;o '+this.settings.prevHtml+' \n "),".lg-item"!==this.settings.appendSubHtmlTo&&(s='
');var n="";this.settings.allowMediaOverlap&&(n+="lg-media-overlap ");var o=this.settings.ariaLabelledby?'aria-labelledby="'+this.settings.ariaLabelledby+'"':"",r=this.settings.ariaDescribedby?'aria-describedby="'+this.settings.ariaDescribedby+'"':"",l="lg-container "+this.settings.addClass+" "+(document.body!==this.settings.container?"lg-inline":""),a=this.settings.closable&&this.settings.showCloseIcon?'':"",g=this.settings.showMaximizeIcon?'':"",d='\n \n ";i(this.settings.container).css("position","relative").append(d),this.outer=this.getElementById("lg-outer"),this.$lgComponents=this.getElementById("lg-components"),this.$backdrop=this.getElementById("lg-backdrop"),this.$container=this.getElementById("lg-container"),this.$inner=this.getElementById("lg-inner"),this.$content=this.getElementById("lg-content"),this.$toolbar=this.getElementById("lg-toolbar"),this.$backdrop.css("transition-duration",this.settings.backdropDuration+"ms");var h=this.settings.mode+" ";this.manageSingleSlideClassName(),this.settings.enableDrag&&(h+="lg-grab "),this.settings.showAfterLoad&&(h+="lg-show-after-load"),this.outer.addClass(h),this.$inner.css("transition-timing-function",this.settings.easing),this.$inner.css("transition-duration",this.settings.speed+"ms"),this.settings.download&&this.$toolbar.append(''),this.counter(),i(window).on("resize.lg.global"+this.lgId+" orientationchange.lg.global"+this.lgId,(function(){t.refreshOnResize()})),this.hideBars(),this.manageCloseGallery(),this.toggleMaximize(),this.initModules()}},s.prototype.refreshOnResize=function(){if(this.lgOpened){var t=this.galleryItems[this.index].__slideVideoInfo;this.mediaContainerPosition=this.getMediaContainerPosition();var e=this.mediaContainerPosition,i=e.top,s=e.bottom;if(this.currentImageSize=o(this.items[this.index],this.outer,i+s,t&&this.settings.videoMaxSize),t&&this.resizeVideoSlide(this.index,this.currentImageSize),this.zoomFromOrigin&&!this.isDummyImageRemoved){var n=this.getDummyImgStyles(this.currentImageSize);this.outer.find(".lg-current .lg-dummy-img").first().attr("style",n)}this.LGel.trigger(y)}},s.prototype.resizeVideoSlide=function(t,e){var i=this.getVideoContStyle(e);this.getSlideItem(t).find(".lg-video-cont").attr("style",i)},s.prototype.updateSlides=function(t,e){if(this.index>t.length-1&&(this.index=t.length-1),1===t.length&&(this.index=0),t.length){var i=this.galleryItems[e].src;this.galleryItems=t,this.updateControls(),this.$inner.empty(),this.currentItemsInDom=[];var s=0;this.galleryItems.some((function(t,e){return t.src===i&&(s=e,!0)})),this.currentItemsInDom=this.organizeSlideItems(s,-1),this.loadContent(s,!0),this.getSlideItem(s).addClass("lg-current"),this.index=s,this.updateCurrentCounter(s),this.LGel.trigger(b)}else this.closeGallery()},s.prototype.getItems=function(){if(this.items=[],this.settings.dynamic)return this.settings.dynamicEl||[];if("this"===this.settings.selector)this.items.push(this.el);else if(this.settings.selector)if("string"==typeof this.settings.selector)if(this.settings.selectWithin){var t=i(this.settings.selectWithin);this.items=t.find(this.settings.selector).get()}else this.items=this.el.querySelectorAll(this.settings.selector);else this.items=this.settings.selector;else this.items=this.el.children;return c(this.items,this.settings.extraProps,this.settings.getCaptionFromTitleOrAlt,this.settings.exThumbImage)},s.prototype.openGallery=function(t,e){var s=this;if(void 0===t&&(t=this.settings.index),!this.lgOpened){this.lgOpened=!0,this.outer.get().focus(),this.outer.removeClass("lg-hide-items"),this.$container.addClass("lg-show");var n=this.getItemsToBeInsertedToDom(t,t);this.currentItemsInDom=n;var l="";n.forEach((function(t){l=l+'
'})),this.$inner.append(l),this.addHtml(t);var a="";this.mediaContainerPosition=this.getMediaContainerPosition();var g=this.mediaContainerPosition,d=g.top,h=g.bottom;this.settings.allowMediaOverlap||this.setMediaContainerPosition(d,h),this.zoomFromOrigin&&e&&(this.currentImageSize=o(e,this.outer,d+h,this.galleryItems[t].__slideVideoInfo&&this.settings.videoMaxSize),a=r(e,this.outer,d,h,this.currentImageSize)),this.zoomFromOrigin&&a||(this.outer.addClass(this.settings.startClass),this.getSlideItem(t).removeClass("lg-complete"));var c=this.settings.zoomFromOrigin?100:this.settings.backdropDuration;setTimeout((function(){s.outer.addClass("lg-components-open")}),c),this.index=t,this.LGel.trigger(I),this.getSlideItem(t).addClass("lg-current"),this.lGalleryOn=!1,this.prevScrollTop=i(window).scrollTop(),setTimeout((function(){if(s.zoomFromOrigin&&a){var e=s.getSlideItem(t);e.css("transform",a),setTimeout((function(){e.addClass("lg-start-progress lg-start-end-progress").css("transition-duration",s.settings.startAnimationDuration+"ms"),s.outer.addClass("lg-zoom-from-image")})),setTimeout((function(){e.css("transform","translate3d(0, 0, 0)")}),100)}setTimeout((function(){s.$backdrop.addClass("in"),s.$container.addClass("lg-show-in")}),10),s.zoomFromOrigin&&a||setTimeout((function(){s.outer.addClass("lg-visible")}),s.settings.backdropDuration),s.slide(t,!1,!1,!1),s.LGel.trigger(w)})),document.body===this.settings.container&&i("html").addClass("lg-on")}},s.prototype.getMediaContainerPosition=function(){if(this.settings.allowMediaOverlap)return{top:0,bottom:0};var t=this.$toolbar.get().clientHeight||0,e=this.outer.find(".lg-components .lg-sub-html").get(),i=this.settings.defaultCaptionHeight||e&&e.clientHeight||0,s=this.outer.find(".lg-thumb-outer").get();return{top:t,bottom:(s?s.clientHeight:0)+i}},s.prototype.setMediaContainerPosition=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.$content.css("top",t+"px").css("bottom",e+"px")},s.prototype.hideBars=function(){var t=this;setTimeout((function(){t.outer.removeClass("lg-hide-items"),t.settings.hideBarsDelay>0&&(t.outer.on("mousemove.lg click.lg touchstart.lg",(function(){t.outer.removeClass("lg-hide-items"),clearTimeout(t.hideBarTimeout),t.hideBarTimeout=setTimeout((function(){t.outer.addClass("lg-hide-items")}),t.settings.hideBarsDelay)})),t.outer.trigger("mousemove.lg"))}),this.settings.showBarsAfter)},s.prototype.initPictureFill=function(t){if(this.settings.supportLegacyBrowser)try{picturefill({elements:[t.get()]})}catch(t){console.warn("lightGallery :- If you want srcset or picture tag to be supported for older browser please include picturefil javascript library in your document.")}},s.prototype.counter=function(){if(this.settings.counter){var t='
\n '+(this.index+1)+' /\n '+this.galleryItems.length+"
";this.outer.find(this.settings.appendCounterTo).append(t)}},s.prototype.addHtml=function(t){var e,s;if(this.galleryItems[t].subHtmlUrl?s=this.galleryItems[t].subHtmlUrl:e=this.galleryItems[t].subHtml,!s)if(e){var n=e.substring(0,1);"."!==n&&"#"!==n||(e=this.settings.subHtmlSelectorRelative&&!this.settings.dynamic?i(this.items).eq(t).find(e).first().html():i(e).first().html())}else e="";if(".lg-item"!==this.settings.appendSubHtmlTo)s?this.outer.find(".lg-sub-html").load(s):this.outer.find(".lg-sub-html").html(e);else{var o=i(this.getSlideItemId(t));s?o.load(s):o.append('
'+e+"
")}null!=e&&(""===e?this.outer.find(this.settings.appendSubHtmlTo).addClass("lg-empty-html"):this.outer.find(this.settings.appendSubHtmlTo).removeClass("lg-empty-html")),this.LGel.trigger(C,{index:t})},s.prototype.preload=function(t){for(var e=1;e<=this.settings.preload&&!(e>=this.galleryItems.length-t);e++)this.loadContent(t+e,!1);for(var i=1;i<=this.settings.preload&&!(t-i<0);i++)this.loadContent(t-i,!1)},s.prototype.getDummyImgStyles=function(t){return t?"width:"+t.width+"px;\n margin-left: -"+t.width/2+"px;\n margin-top: -"+t.height/2+"px;\n height:"+t.height+"px":""},s.prototype.getVideoContStyle=function(t){return t?"width:"+t.width+"px;\n height:"+t.height+"px":""},s.prototype.getDummyImageContent=function(t,e,s){var n;if(this.settings.dynamic||(n=i(this.items).eq(e)),n){var o=void 0;if(!(o=this.settings.exThumbImage?n.attr(this.settings.exThumbImage):n.find("img").first().attr("src")))return"";var r="';return t.addClass("lg-first-slide"),this.outer.addClass("lg-first-slide-loading"),r}return""},s.prototype.setImgMarkup=function(t,e,i){var s=this.galleryItems[i],n=s.alt,o=s.srcset,r=s.sizes,l=s.sources,g=n?'alt="'+n+'"':"",d=' '+(!this.lGalleryOn&&this.zoomFromOrigin&&this.currentImageSize?this.getDummyImageContent(e,i,g):a(i,t,g,o,r,l))+"";e.prepend(d)},s.prototype.onLgObjectLoad=function(t,e,i,s,n){var o=this;n&&this.LGel.trigger(x,{index:e,delay:i||0}),t.find(".lg-object").first().on("load.lg",(function(){o.handleLgObjectLoad(t,e,i,s,n)})),setTimeout((function(){t.find(".lg-object").first().on("error.lg",(function(){t.addClass("lg-complete lg-complete_"),t.html('Oops... Failed to load content...')}))}),s)},s.prototype.handleLgObjectLoad=function(t,e,i,s,n){var o=this;setTimeout((function(){t.addClass("lg-complete lg-complete_"),n||o.LGel.trigger(x,{index:e,delay:i||0})}),s)},s.prototype.isVideo=function(t,e){if(!t)return this.galleryItems[e].video?{html5:!0}:void console.error("lightGallery :- data-src is not provided on slide item "+(e+1)+". Please make sure the selector property is properly configured. More info - https://www.lightgalleryjs.com/demos/html-markup/");var i=t.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)/i),s=t.match(/\/\/(?:www\.)?(?:player\.)?vimeo.com\/(?:video\/)?([0-9a-z\-_]+)/i),n=t.match(/https?:\/\/(.+)?(wistia\.com|wi\.st)\/(medias|embed)\/([0-9a-z\-_]+)(.*)/);return i?{youtube:i}:s?{vimeo:s}:n?{wistia:n}:void 0},s.prototype.addSlideVideoInfo=function(t){var e=this;t.forEach((function(t,i){t.__slideVideoInfo=e.isVideo(t.src,i)}))},s.prototype.loadContent=function(t,e){var s=this,n=this.galleryItems[t],r=i(this.getSlideItemId(t)),c=n.poster,u=n.srcset,m=n.sizes,f=n.sources,y=n.src,b=n.video,C=b&&"string"==typeof b?JSON.parse(b):b;if(n.responsive){var I=n.responsive.split(",");y=g(I)||y}var w=n.__slideVideoInfo,x="",S=!!n.iframe;if(!r.hasClass("lg-loaded")){if(w){var T=this.mediaContainerPosition,E=T.top,O=T.bottom,L=o(this.items[t],this.outer,E+O,w&&this.settings.videoMaxSize);x=this.getVideoContStyle(L)}if(S){var D=l(this.settings.iframeWidth,this.settings.iframeHeight,y,n.iframeTitle);r.prepend(D)}else if(c){var z="",G=!this.lGalleryOn,M=!this.lGalleryOn&&this.zoomFromOrigin&&this.currentImageSize;M&&(z=this.getDummyImageContent(r,t,""));D=h(c,z||"",x,w);r.prepend(D);var k=(M?this.settings.startAnimationDuration:this.settings.backdropDuration)+100;setTimeout((function(){s.LGel.trigger(v,{index:t,src:y,html5Video:C,hasPoster:!0,isFirstSlide:G})}),k)}else if(w){D='
';r.prepend(D),this.LGel.trigger(v,{index:t,src:y,html5Video:C,hasPoster:!1})}else if(this.setImgMarkup(y,r,t),u||f){var A=r.find(".lg-object");this.initPictureFill(A)}this.LGel.trigger(p,{index:t}),this.lGalleryOn&&".lg-item"===this.settings.appendSubHtmlTo&&this.addHtml(t)}var B=0,P=0;this.lGalleryOn||(P=this.zoomFromOrigin&&this.currentImageSize?this.settings.startAnimationDuration+10:this.settings.backdropDuration+10),P&&!i(document.body).hasClass("lg-from-hash")&&(B=P),!this.lGalleryOn&&this.zoomFromOrigin&&this.currentImageSize&&(setTimeout((function(){r.removeClass("lg-start-end-progress lg-start-progress").removeAttr("style")}),this.settings.startAnimationDuration+100),r.hasClass("lg-loaded")||setTimeout((function(){if(r.find(".lg-img-wrap").append(a(t,y,"",u,m,n.sources)),u||f){var e=r.find(".lg-object");s.initPictureFill(e)}s.onLgObjectLoad(r,t,P,B,!0);var i=r.find(".lg-object").first();d(i.get())?s.loadContentOnLoad(t,r,B):i.on("load.lg error.lg",(function(){s.loadContentOnLoad(t,r,B)}))}),this.settings.startAnimationDuration+100)),r.addClass("lg-loaded"),this.onLgObjectLoad(r,t,P,B,!1),w&&w.html5&&!c&&r.addClass("lg-complete lg-complete_"),this.zoomFromOrigin&&this.currentImageSize||!r.hasClass("lg-complete_")||this.lGalleryOn||setTimeout((function(){r.addClass("lg-complete")}),this.settings.backdropDuration),this.lGalleryOn=!0,!0===e&&(r.hasClass("lg-complete_")?this.preload(t):r.find(".lg-object").first().on("load.lg error.lg",(function(){s.preload(t)})))},s.prototype.loadContentOnLoad=function(t,e,i){var s=this;setTimeout((function(){e.find(".lg-dummy-img").remove(),e.removeClass("lg-first-slide"),s.outer.removeClass("lg-first-slide-loading"),s.isDummyImageRemoved=!0,s.preload(t)}),i+300)},s.prototype.getItemsToBeInsertedToDom=function(t,e,i){var s=this;void 0===i&&(i=0);var n=[],o=Math.max(i,3);o=Math.min(o,this.galleryItems.length);var r="lg-item-"+this.lgId+"-"+e;if(this.galleryItems.length<=3)return this.galleryItems.forEach((function(t,e){n.push("lg-item-"+s.lgId+"-"+e)})),n;if(t<(this.galleryItems.length-1)/2){for(var l=t;l>t-o/2&&l>=0;l--)n.push("lg-item-"+this.lgId+"-"+l);var a=n.length;for(l=0;l')})),this.currentItemsInDom.forEach((function(t){-1===n.indexOf(t)&&i("#"+t).remove()})),n},s.prototype.getPreviousSlideIndex=function(){var t=0;try{var e=this.outer.find(".lg-current").first().attr("id");t=parseInt(e.split("-")[3])||0}catch(e){t=0}return t},s.prototype.setDownloadValue=function(t){if(this.settings.download){var e=this.galleryItems[t];if(!1===e.downloadUrl||"false"===e.downloadUrl)this.outer.addClass("lg-hide-download");else{var i=this.getElementById("lg-download");this.outer.removeClass("lg-hide-download"),i.attr("href",e.downloadUrl||e.src),e.download&&i.attr("download",e.download)}}},s.prototype.makeSlideAnimation=function(t,e,i){var s=this;this.lGalleryOn&&i.addClass("lg-slide-progress"),setTimeout((function(){s.outer.addClass("lg-no-trans"),s.outer.find(".lg-item").removeClass("lg-prev-slide lg-next-slide"),"prev"===t?(e.addClass("lg-prev-slide"),i.addClass("lg-next-slide")):(e.addClass("lg-next-slide"),i.addClass("lg-prev-slide")),setTimeout((function(){s.outer.find(".lg-item").removeClass("lg-current"),e.addClass("lg-current"),s.outer.removeClass("lg-no-trans")}),50)}),this.lGalleryOn?this.settings.slideDelay:0)},s.prototype.slide=function(t,e,i,s){var n=this,r=this.getPreviousSlideIndex();if(this.currentItemsInDom=this.organizeSlideItems(t,r),!this.lGalleryOn||r!==t){var l=this.galleryItems.length;if(!this.lgBusy){this.settings.counter&&this.updateCurrentCounter(t);var a=this.getSlideItem(t),g=this.getSlideItem(r),d=this.galleryItems[t],h=d.__slideVideoInfo;if(this.outer.attr("data-lg-slide-type",this.getSlideType(d)),this.setDownloadValue(t),h){var c=this.mediaContainerPosition,u=c.top,m=c.bottom,p=o(this.items[t],this.outer,u+m,h&&this.settings.videoMaxSize);this.resizeVideoSlide(t,p)}if(this.LGel.trigger(S,{prevIndex:r,index:t,fromTouch:!!e,fromThumb:!!i}),this.lgBusy=!0,clearTimeout(this.hideBarTimeout),this.arrowDisable(t),s||(tr&&(s="next")),e){this.outer.find(".lg-item").removeClass("lg-prev-slide lg-current lg-next-slide");var f=void 0,v=void 0;l>2?(f=t-1,v=t+1,(0===t&&r===l-1||t===l-1&&0===r)&&(v=0,f=l-1)):(f=0,v=1),"prev"===s?this.getSlideItem(v).addClass("lg-next-slide"):this.getSlideItem(f).addClass("lg-prev-slide"),a.addClass("lg-current")}else this.makeSlideAnimation(s,a,g);this.lGalleryOn||this.loadContent(t,!0),setTimeout((function(){n.lGalleryOn&&n.loadContent(t,!0),".lg-item"!==n.settings.appendSubHtmlTo&&n.addHtml(t)}),(this.lGalleryOn?this.settings.speed+50:50)+(e?0:this.settings.slideDelay)),setTimeout((function(){n.lgBusy=!1,g.removeClass("lg-slide-progress"),n.LGel.trigger(T,{prevIndex:r,index:t,fromTouch:e,fromThumb:i})}),(this.lGalleryOn?this.settings.speed+100:100)+(e?0:this.settings.slideDelay))}this.index=t}},s.prototype.updateCurrentCounter=function(t){this.getElementById("lg-counter-current").html(t+1+"")},s.prototype.updateCounterTotal=function(){this.getElementById("lg-counter-all").html(this.galleryItems.length+"")},s.prototype.getSlideType=function(t){return t.__slideVideoInfo?"video":t.iframe?"iframe":"image"},s.prototype.touchMove=function(t,e,i){var s=e.pageX-t.pageX,n=e.pageY-t.pageY,o=!1;if(this.swipeDirection?o=!0:Math.abs(s)>15?(this.swipeDirection="horizontal",o=!0):Math.abs(n)>15&&(this.swipeDirection="vertical",o=!0),o){var r=this.getSlideItem(this.index);if("horizontal"===this.swipeDirection){null==i||i.preventDefault(),this.outer.addClass("lg-dragging"),this.setTranslate(r,s,0);var l=r.get().offsetWidth,a=15*l/100-Math.abs(10*s/100);this.setTranslate(this.outer.find(".lg-prev-slide").first(),-l+s-a,0),this.setTranslate(this.outer.find(".lg-next-slide").first(),l+s+a,0)}else if("vertical"===this.swipeDirection&&this.settings.swipeToClose){null==i||i.preventDefault(),this.$container.addClass("lg-dragging-vertical");var g=1-Math.abs(n)/window.innerHeight;this.$backdrop.css("opacity",g);var d=1-Math.abs(n)/(2*window.innerWidth);this.setTranslate(r,0,n,d,d),Math.abs(n)>100&&this.outer.addClass("lg-hide-items").removeClass("lg-components-open")}}},s.prototype.touchEnd=function(t,e,s){var n,o=this;"lg-slide"!==this.settings.mode&&this.outer.addClass("lg-slide"),setTimeout((function(){o.$container.removeClass("lg-dragging-vertical"),o.outer.removeClass("lg-dragging lg-hide-items").addClass("lg-components-open");var r=!0;if("horizontal"===o.swipeDirection){n=t.pageX-e.pageX;var l=Math.abs(t.pageX-e.pageX);n<0&&l>o.settings.swipeThreshold?(o.goToNextSlide(!0),r=!1):n>0&&l>o.settings.swipeThreshold&&(o.goToPrevSlide(!0),r=!1)}else if("vertical"===o.swipeDirection){if(n=Math.abs(t.pageY-e.pageY),o.settings.closable&&o.settings.swipeToClose&&n>100)return void o.closeGallery();o.$backdrop.css("opacity",1)}if(o.outer.find(".lg-item").removeAttr("style"),r&&Math.abs(t.pageX-e.pageX)<5){var a=i(s.target);o.isPosterElement(a)&&o.LGel.trigger(E)}o.swipeDirection=void 0})),setTimeout((function(){o.outer.hasClass("lg-dragging")||"lg-slide"===o.settings.mode||o.outer.removeClass("lg-slide")}),this.settings.speed+100)},s.prototype.enableSwipe=function(){var t=this,e={},s={},n=!1,o=!1;this.settings.enableSwipe&&(this.$inner.on("touchstart.lg",(function(s){t.dragOrSwipeEnabled=!0;var n=t.getSlideItem(t.index);!i(s.target).hasClass("lg-item")&&!n.get().contains(s.target)||t.outer.hasClass("lg-zoomed")||t.lgBusy||1!==s.targetTouches.length||(o=!0,t.touchAction="swipe",t.manageSwipeClass(),e={pageX:s.targetTouches[0].pageX,pageY:s.targetTouches[0].pageY})})),this.$inner.on("touchmove.lg",(function(i){o&&"swipe"===t.touchAction&&1===i.targetTouches.length&&(s={pageX:i.targetTouches[0].pageX,pageY:i.targetTouches[0].pageY},t.touchMove(e,s,i),n=!0)})),this.$inner.on("touchend.lg",(function(r){if("swipe"===t.touchAction){if(n)n=!1,t.touchEnd(s,e,r);else if(o){var l=i(r.target);t.isPosterElement(l)&&t.LGel.trigger(E)}t.touchAction=void 0,o=!1}})))},s.prototype.enableDrag=function(){var t=this,e={},s={},n=!1,o=!1;this.settings.enableDrag&&(this.outer.on("mousedown.lg",(function(s){t.dragOrSwipeEnabled=!0;var o=t.getSlideItem(t.index);(i(s.target).hasClass("lg-item")||o.get().contains(s.target))&&(t.outer.hasClass("lg-zoomed")||t.lgBusy||(s.preventDefault(),t.lgBusy||(t.manageSwipeClass(),e={pageX:s.pageX,pageY:s.pageY},n=!0,t.outer.get().scrollLeft+=1,t.outer.get().scrollLeft-=1,t.outer.removeClass("lg-grab").addClass("lg-grabbing"),t.LGel.trigger(O))))})),i(window).on("mousemove.lg.global"+this.lgId,(function(i){n&&t.lgOpened&&(o=!0,s={pageX:i.pageX,pageY:i.pageY},t.touchMove(e,s),t.LGel.trigger(L))})),i(window).on("mouseup.lg.global"+this.lgId,(function(r){if(t.lgOpened){var l=i(r.target);o?(o=!1,t.touchEnd(s,e,r),t.LGel.trigger(D)):t.isPosterElement(l)&&t.LGel.trigger(E),n&&(n=!1,t.outer.removeClass("lg-grabbing").addClass("lg-grab"))}})))},s.prototype.triggerPosterClick=function(){var t=this;this.$inner.on("click.lg",(function(e){!t.dragOrSwipeEnabled&&t.isPosterElement(i(e.target))&&t.LGel.trigger(E)}))},s.prototype.manageSwipeClass=function(){var t=this.index+1,e=this.index-1;this.settings.loop&&this.galleryItems.length>2&&(0===this.index?e=this.galleryItems.length-1:this.index===this.galleryItems.length-1&&(t=0)),this.outer.find(".lg-item").removeClass("lg-next-slide lg-prev-slide"),e>-1&&this.getSlideItem(e).addClass("lg-prev-slide"),this.getSlideItem(t).addClass("lg-next-slide")},s.prototype.goToNextSlide=function(t){var e=this,i=this.settings.loop;t&&this.galleryItems.length<3&&(i=!1),this.lgBusy||(this.index+10?(this.index--,this.LGel.trigger(G,{index:this.index,fromTouch:t}),this.slide(this.index,!!t,!1,"prev")):i?(this.index=this.galleryItems.length-1,this.LGel.trigger(G,{index:this.index,fromTouch:t}),this.slide(this.index,!!t,!1,"prev")):this.settings.slideEndAnimation&&!t&&(this.outer.addClass("lg-left-end"),setTimeout((function(){e.outer.removeClass("lg-left-end")}),400)))},s.prototype.keyPress=function(){var t=this;i(window).on("keydown.lg.global"+this.lgId,(function(e){t.lgOpened&&!0===t.settings.escKey&&27===e.keyCode&&(e.preventDefault(),t.settings.allowMediaOverlap&&t.outer.hasClass("lg-can-toggle")&&t.outer.hasClass("lg-components-open")?t.outer.removeClass("lg-components-open"):t.closeGallery()),t.lgOpened&&t.galleryItems.length>1&&(37===e.keyCode&&(e.preventDefault(),t.goToPrevSlide()),39===e.keyCode&&(e.preventDefault(),t.goToNextSlide()))}))},s.prototype.arrow=function(){var t=this;this.getElementById("lg-prev").on("click.lg",(function(){t.goToPrevSlide()})),this.getElementById("lg-next").on("click.lg",(function(){t.goToNextSlide()}))},s.prototype.arrowDisable=function(t){if(!this.settings.loop&&this.settings.hideControlOnEnd){var e=this.getElementById("lg-prev"),i=this.getElementById("lg-next");t+1===this.galleryItems.length?i.attr("disabled","disabled").addClass("disabled"):i.removeAttr("disabled").removeClass("disabled"),0===t?e.attr("disabled","disabled").addClass("disabled"):e.removeAttr("disabled").removeClass("disabled")}},s.prototype.setTranslate=function(t,e,i,s,n){void 0===s&&(s=1),void 0===n&&(n=1),t.css("transform","translate3d("+e+"px, "+i+"px, 0px) scale3d("+s+", "+n+", 1)")},s.prototype.mousewheel=function(){var t=this;this.outer.on("mousewheel.lg",(function(e){!e.deltaY||t.galleryItems.length<2||(e.deltaY>0?t.goToPrevSlide():t.goToNextSlide(),e.preventDefault())}))},s.prototype.isSlideElement=function(t){return t.hasClass("lg-outer")||t.hasClass("lg-item")||t.hasClass("lg-img-wrap")},s.prototype.isPosterElement=function(t){var e=this.getSlideItem(this.index).find(".lg-video-play-button").get();return t.hasClass("lg-video-poster")||t.hasClass("lg-video-play-button")||e&&e.contains(t.get())},s.prototype.toggleMaximize=function(){var t=this;this.getElementById("lg-maximize").on("click.lg",(function(){t.$container.toggleClass("lg-inline"),t.refreshOnResize()}))},s.prototype.invalidateItems=function(){for(var t=0;ta){r=d;break}g===l.length-1&&(r=d)}var h=r.split("-"),c=parseInt(h[0],10),u=parseInt(h[1],10),m=e.width(),p=e.height()-s,f=Math.min(m,c),v=Math.min(p,u),y=Math.min(f/c,v/u);return{width:c*y,height:u*y}}},r=function(t,e,s,n,o){if(o){var r=i(t).find("img").first();if(r.get()){var l=e.get().getBoundingClientRect(),a=l.width,g=e.height()-(s+n),d=r.width(),h=r.height(),c=r.style(),u=(a-d)/2-r.offset().left+(parseFloat(c.paddingLeft)||0)+(parseFloat(c.borderLeft)||0)+i(window).scrollLeft()+l.left,m=(g-h)/2-r.offset().top+(parseFloat(c.paddingTop)||0)+(parseFloat(c.borderTop)||0)+i(window).scrollTop()+s;return"translate3d("+(u*=-1)+"px, "+(m*=-1)+"px, 0) scale3d("+d/o.width+", "+h/o.height+", 1)"}}},l=function(t,e,i,s){return'
\n \n
'},a=function(t,e,i,s,n,o){var r="',l="";o&&(l=("string"==typeof o?JSON.parse(o):o).map((function(t){var e="";return Object.keys(t).forEach((function(i){e+=" "+i+'="'+t[i]+'"'})),""})));return""+l+r},g=function(t){for(var e=[],i=[],s="",n=0;nr){s=i[l];break}return s},d=function(t){return!!t&&(!!t.complete&&0!==t.naturalWidth)},h=function(t,e,i,s){return'
\n
\n \n Play video\n \n \n \n \n \n \n \n
\n '+(e||"")+'\n \n
'},c=function(t,e,o,r){var l=[],a=function(){for(var t=0,e=0,i=arguments.length;e-1&&(h=d),h&&(e[h]=g.value)}}var c=i(t),u=c.find("img").first().attr("alt"),m=c.attr("title"),p=r?c.attr(r):c.find("img").first().attr("src");e.thumb=p,o&&!e.subHtml&&(e.subHtml=m||u||""),e.alt=u||m||"",l.push(e)})),l},u=function(){return/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)},m={mode:"lg-slide",easing:"ease",speed:400,licenseKey:"0000-0000-000-0000",height:"100%",width:"100%",addClass:"",startClass:"lg-start-zoom",backdropDuration:300,container:document.body,startAnimationDuration:400,zoomFromOrigin:!0,hideBarsDelay:0,showBarsAfter:1e4,slideDelay:0,supportLegacyBrowser:!0,allowMediaOverlap:!1,videoMaxSize:"1280-720",defaultCaptionHeight:0,ariaLabelledby:"",ariaDescribedby:"",closable:!0,swipeToClose:!0,closeOnTap:!0,showCloseIcon:!0,showMaximizeIcon:!1,loop:!0,escKey:!0,keyPress:!0,controls:!0,slideEndAnimation:!0,hideControlOnEnd:!1,mousewheel:!1,getCaptionFromTitleOrAlt:!0,appendSubHtmlTo:".lg-sub-html",subHtmlSelectorRelative:!1,preload:2,numberOfSlideItemsInDom:10,showAfterLoad:!0,selector:"",selectWithin:"",nextHtml:"",prevHtml:"",index:0,iframeWidth:"100%",iframeHeight:"100%",download:!0,counter:!0,appendCounterTo:".lg-toolbar",swipeThreshold:50,enableSwipe:!0,enableDrag:!0,dynamic:!1,dynamicEl:[],extraProps:[],exThumbImage:"",isMobile:void 0,mobileSettings:{controls:!1,showCloseIcon:!1,download:!1},plugins:[]},p="lgAfterAppendSlide",f="lgInit",v="lgHasVideo",y="lgContainerResize",b="lgUpdateSlides",C="lgAfterAppendSubHtml",I="lgBeforeOpen",w="lgAfterOpen",x="lgSlideItemLoad",S="lgBeforeSlide",T="lgAfterSlide",E="lgPosterClick",O="lgDragStart",L="lgDragMove",z="lgDragEnd",D="lgBeforeNextSlide",G="lgBeforePrevSlide",M="lgBeforeClose",k="lgAfterClose",A=0,B=function(){function s(t,e){if(this.lgOpened=!1,this.index=0,this.plugins=[],this.lGalleryOn=!1,this.lgBusy=!1,this.currentItemsInDom=[],this.prevScrollTop=0,this.isDummyImageRemoved=!1,this.dragOrSwipeEnabled=!1,this.mediaContainerPosition={top:0,bottom:0},!t)return this;if(A++,this.lgId=A,this.el=t,this.LGel=i(t),this.generateSettings(e),this.buildModules(),this.settings.dynamic&&void 0!==this.settings.dynamicEl&&!Array.isArray(this.settings.dynamicEl))throw"When using dynamic mode, you must also define dynamicEl as an Array.";return this.galleryItems=this.getItems(),this.normalizeSettings(),this.init(),this.validateLicense(),this}return s.prototype.generateSettings=function(e){if(this.settings=t(t({},m),e),this.settings.isMobile&&"function"==typeof this.settings.isMobile?this.settings.isMobile():u()){var i=t(t({},this.settings.mobileSettings),this.settings.mobileSettings);this.settings=t(t({},this.settings),i)}},s.prototype.normalizeSettings=function(){this.settings.slideEndAnimation&&(this.settings.hideControlOnEnd=!1),this.settings.closable||(this.settings.swipeToClose=!1),this.zoomFromOrigin=this.settings.zoomFromOrigin,this.settings.dynamic&&(this.zoomFromOrigin=!1),this.settings.container||(this.settings.container=document.body),this.settings.preload=Math.min(this.settings.preload,this.galleryItems.length)},s.prototype.init=function(){var t=this;this.addSlideVideoInfo(this.galleryItems),this.buildStructure(),this.LGel.trigger(f,{instance:this}),this.settings.keyPress&&this.keyPress(),setTimeout((function(){t.enableDrag(),t.enableSwipe(),t.triggerPosterClick()}),50),this.arrow(),this.settings.mousewheel&&this.mousewheel(),this.settings.dynamic||this.openGalleryOnItemClick()},s.prototype.openGalleryOnItemClick=function(){for(var t=this,s=function(s){var o=n.items[s],r=i(o),l=e.generateUUID();r.attr("data-lg-id",l).on("click.lgcustom-item-"+l,(function(e){e.preventDefault();var i=t.settings.index||s;t.openGallery(i,o)}))},n=this,o=0;o '+this.settings.prevHtml+' \n "),".lg-item"!==this.settings.appendSubHtmlTo&&(s='
');var n="";this.settings.allowMediaOverlap&&(n+="lg-media-overlap ");var o=this.settings.ariaLabelledby?'aria-labelledby="'+this.settings.ariaLabelledby+'"':"",r=this.settings.ariaDescribedby?'aria-describedby="'+this.settings.ariaDescribedby+'"':"",l="lg-container "+this.settings.addClass+" "+(document.body!==this.settings.container?"lg-inline":""),a=this.settings.closable&&this.settings.showCloseIcon?'':"",g=this.settings.showMaximizeIcon?'':"",d='\n \n ";i(this.settings.container).css("position","relative").append(d),this.outer=this.getElementById("lg-outer"),this.$lgComponents=this.getElementById("lg-components"),this.$backdrop=this.getElementById("lg-backdrop"),this.$container=this.getElementById("lg-container"),this.$inner=this.getElementById("lg-inner"),this.$content=this.getElementById("lg-content"),this.$toolbar=this.getElementById("lg-toolbar"),this.$backdrop.css("transition-duration",this.settings.backdropDuration+"ms");var h=this.settings.mode+" ";this.manageSingleSlideClassName(),this.settings.enableDrag&&(h+="lg-grab "),this.settings.showAfterLoad&&(h+="lg-show-after-load"),this.outer.addClass(h),this.$inner.css("transition-timing-function",this.settings.easing),this.$inner.css("transition-duration",this.settings.speed+"ms"),this.settings.download&&this.$toolbar.append(''),this.counter(),i(window).on("resize.lg.global"+this.lgId+" orientationchange.lg.global"+this.lgId,(function(){t.refreshOnResize()})),this.hideBars(),this.manageCloseGallery(),this.toggleMaximize(),this.initModules()}},s.prototype.refreshOnResize=function(){if(this.lgOpened){var t=this.galleryItems[this.index],e=t.__slideVideoInfo,i=t.poster;this.mediaContainerPosition=this.getMediaContainerPosition();var s=this.mediaContainerPosition,n=s.top,r=s.bottom;if(this.currentImageSize=o(this.items[this.index],this.outer,n+r,e&&!i,e&&this.settings.videoMaxSize),e&&this.resizeVideoSlide(this.index,this.currentImageSize),this.zoomFromOrigin&&!this.isDummyImageRemoved){var l=this.getDummyImgStyles(this.currentImageSize);this.outer.find(".lg-current .lg-dummy-img").first().attr("style",l)}this.LGel.trigger(y)}},s.prototype.resizeVideoSlide=function(t,e){var i=this.getVideoContStyle(e);this.getSlideItem(t).find(".lg-video-cont").attr("style",i)},s.prototype.updateSlides=function(t,e){if(this.index>t.length-1&&(this.index=t.length-1),1===t.length&&(this.index=0),t.length){var i=this.galleryItems[e].src;this.galleryItems=t,this.updateControls(),this.$inner.empty(),this.currentItemsInDom=[];var s=0;this.galleryItems.some((function(t,e){return t.src===i&&(s=e,!0)})),this.currentItemsInDom=this.organizeSlideItems(s,-1),this.loadContent(s,!0),this.getSlideItem(s).addClass("lg-current"),this.index=s,this.updateCurrentCounter(s),this.LGel.trigger(b)}else this.closeGallery()},s.prototype.getItems=function(){if(this.items=[],this.settings.dynamic)return this.settings.dynamicEl||[];if("this"===this.settings.selector)this.items.push(this.el);else if(this.settings.selector)if("string"==typeof this.settings.selector)if(this.settings.selectWithin){var t=i(this.settings.selectWithin);this.items=t.find(this.settings.selector).get()}else this.items=this.el.querySelectorAll(this.settings.selector);else this.items=this.settings.selector;else this.items=this.el.children;return c(this.items,this.settings.extraProps,this.settings.getCaptionFromTitleOrAlt,this.settings.exThumbImage)},s.prototype.openGallery=function(t,e){var s=this;if(void 0===t&&(t=this.settings.index),!this.lgOpened){this.lgOpened=!0,this.outer.get().focus(),this.outer.removeClass("lg-hide-items"),this.$container.addClass("lg-show");var n=this.getItemsToBeInsertedToDom(t,t);this.currentItemsInDom=n;var l="";n.forEach((function(t){l=l+'
'})),this.$inner.append(l),this.addHtml(t);var a="";this.mediaContainerPosition=this.getMediaContainerPosition();var g=this.mediaContainerPosition,d=g.top,h=g.bottom;this.settings.allowMediaOverlap||this.setMediaContainerPosition(d,h);var c=this.galleryItems[t],u=c.__slideVideoInfo,m=c.poster;this.zoomFromOrigin&&e&&(this.currentImageSize=o(e,this.outer,d+h,u&&!m,u&&this.settings.videoMaxSize),a=r(e,this.outer,d,h,this.currentImageSize)),this.zoomFromOrigin&&a||(this.outer.addClass(this.settings.startClass),this.getSlideItem(t).removeClass("lg-complete"));var p=this.settings.zoomFromOrigin?100:this.settings.backdropDuration;setTimeout((function(){s.outer.addClass("lg-components-open")}),p),this.index=t,this.LGel.trigger(I),this.getSlideItem(t).addClass("lg-current"),this.lGalleryOn=!1,this.prevScrollTop=i(window).scrollTop(),setTimeout((function(){if(s.zoomFromOrigin&&a){var e=s.getSlideItem(t);e.css("transform",a),setTimeout((function(){e.addClass("lg-start-progress lg-start-end-progress").css("transition-duration",s.settings.startAnimationDuration+"ms"),s.outer.addClass("lg-zoom-from-image")})),setTimeout((function(){e.css("transform","translate3d(0, 0, 0)")}),100)}setTimeout((function(){s.$backdrop.addClass("in"),s.$container.addClass("lg-show-in")}),10),s.zoomFromOrigin&&a||setTimeout((function(){s.outer.addClass("lg-visible")}),s.settings.backdropDuration),s.slide(t,!1,!1,!1),s.LGel.trigger(w)})),document.body===this.settings.container&&i("html").addClass("lg-on")}},s.prototype.getMediaContainerPosition=function(){if(this.settings.allowMediaOverlap)return{top:0,bottom:0};var t=this.$toolbar.get().clientHeight||0,e=this.outer.find(".lg-components .lg-sub-html").get(),i=this.settings.defaultCaptionHeight||e&&e.clientHeight||0,s=this.outer.find(".lg-thumb-outer").get();return{top:t,bottom:(s?s.clientHeight:0)+i}},s.prototype.setMediaContainerPosition=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.$content.css("top",t+"px").css("bottom",e+"px")},s.prototype.hideBars=function(){var t=this;setTimeout((function(){t.outer.removeClass("lg-hide-items"),t.settings.hideBarsDelay>0&&(t.outer.on("mousemove.lg click.lg touchstart.lg",(function(){t.outer.removeClass("lg-hide-items"),clearTimeout(t.hideBarTimeout),t.hideBarTimeout=setTimeout((function(){t.outer.addClass("lg-hide-items")}),t.settings.hideBarsDelay)})),t.outer.trigger("mousemove.lg"))}),this.settings.showBarsAfter)},s.prototype.initPictureFill=function(t){if(this.settings.supportLegacyBrowser)try{picturefill({elements:[t.get()]})}catch(t){console.warn("lightGallery :- If you want srcset or picture tag to be supported for older browser please include picturefil javascript library in your document.")}},s.prototype.counter=function(){if(this.settings.counter){var t='
\n '+(this.index+1)+' /\n '+this.galleryItems.length+"
";this.outer.find(this.settings.appendCounterTo).append(t)}},s.prototype.addHtml=function(t){var e,s;if(this.galleryItems[t].subHtmlUrl?s=this.galleryItems[t].subHtmlUrl:e=this.galleryItems[t].subHtml,!s)if(e){var n=e.substring(0,1);"."!==n&&"#"!==n||(e=this.settings.subHtmlSelectorRelative&&!this.settings.dynamic?i(this.items).eq(t).find(e).first().html():i(e).first().html())}else e="";if(".lg-item"!==this.settings.appendSubHtmlTo)s?this.outer.find(".lg-sub-html").load(s):this.outer.find(".lg-sub-html").html(e);else{var o=i(this.getSlideItemId(t));s?o.load(s):o.append('
'+e+"
")}null!=e&&(""===e?this.outer.find(this.settings.appendSubHtmlTo).addClass("lg-empty-html"):this.outer.find(this.settings.appendSubHtmlTo).removeClass("lg-empty-html")),this.LGel.trigger(C,{index:t})},s.prototype.preload=function(t){for(var e=1;e<=this.settings.preload&&!(e>=this.galleryItems.length-t);e++)this.loadContent(t+e,!1);for(var i=1;i<=this.settings.preload&&!(t-i<0);i++)this.loadContent(t-i,!1)},s.prototype.getDummyImgStyles=function(t){return t?"width:"+t.width+"px;\n margin-left: -"+t.width/2+"px;\n margin-top: -"+t.height/2+"px;\n height:"+t.height+"px":""},s.prototype.getVideoContStyle=function(t){return t?"width:"+t.width+"px;\n height:"+t.height+"px":""},s.prototype.getDummyImageContent=function(t,e,s){var n;if(this.settings.dynamic||(n=i(this.items).eq(e)),n){var o=void 0;if(!(o=this.settings.exThumbImage?n.attr(this.settings.exThumbImage):n.find("img").first().attr("src")))return"";var r="';return t.addClass("lg-first-slide"),this.outer.addClass("lg-first-slide-loading"),r}return""},s.prototype.setImgMarkup=function(t,e,i){var s=this.galleryItems[i],n=s.alt,o=s.srcset,r=s.sizes,l=s.sources,g=n?'alt="'+n+'"':"",d=' '+(!this.lGalleryOn&&this.zoomFromOrigin&&this.currentImageSize?this.getDummyImageContent(e,i,g):a(i,t,g,o,r,l))+"";e.prepend(d)},s.prototype.onLgObjectLoad=function(t,e,i,s,n,o){var r=this;n&&this.LGel.trigger(x,{index:e,delay:i||0,isFirstSlide:o}),t.find(".lg-object").first().on("load.lg",(function(){r.handleLgObjectLoad(t,e,i,s,n,o)})),setTimeout((function(){t.find(".lg-object").first().on("error.lg",(function(){t.addClass("lg-complete lg-complete_"),t.html('Oops... Failed to load content...')}))}),s)},s.prototype.handleLgObjectLoad=function(t,e,i,s,n,o){var r=this;setTimeout((function(){t.addClass("lg-complete lg-complete_"),n||r.LGel.trigger(x,{index:e,delay:i||0,isFirstSlide:o})}),s)},s.prototype.isVideo=function(t,e){if(!t)return this.galleryItems[e].video?{html5:!0}:void console.error("lightGallery :- data-src is not provided on slide item "+(e+1)+". Please make sure the selector property is properly configured. More info - https://www.lightgalleryjs.com/demos/html-markup/");var i=t.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)([\&|?][\S]*)*/i),s=t.match(/\/\/(?:www\.)?(?:player\.)?vimeo.com\/(?:video\/)?([0-9a-z\-_]+)/i),n=t.match(/https?:\/\/(.+)?(wistia\.com|wi\.st)\/(medias|embed)\/([0-9a-z\-_]+)(.*)/);return i?{youtube:i}:s?{vimeo:s}:n?{wistia:n}:void 0},s.prototype.addSlideVideoInfo=function(t){var e=this;t.forEach((function(t,i){t.__slideVideoInfo=e.isVideo(t.src,i)}))},s.prototype.loadContent=function(t,e){var s=this,n=this.galleryItems[t],r=i(this.getSlideItemId(t)),c=n.poster,u=n.srcset,m=n.sizes,f=n.sources,y=n.src,b=n.video,C=b&&"string"==typeof b?JSON.parse(b):b;if(n.responsive){var I=n.responsive.split(",");y=g(I)||y}var w=n.__slideVideoInfo,x="",S=!!n.iframe,T=!this.lGalleryOn,E=0;if(T&&(E=this.zoomFromOrigin&&this.currentImageSize?this.settings.startAnimationDuration+10:this.settings.backdropDuration+10),!r.hasClass("lg-loaded")){if(w){var O=this.mediaContainerPosition,L=O.top,z=O.bottom,D=o(this.items[t],this.outer,L+z,!1,w&&this.settings.videoMaxSize);x=this.getVideoContStyle(D)}if(S){var G=l(this.settings.iframeWidth,this.settings.iframeHeight,y,n.iframeTitle);r.prepend(G)}else if(c){var M="";T&&this.zoomFromOrigin&&this.currentImageSize&&(M=this.getDummyImageContent(r,t,""));G=h(c,M||"",x,w);r.prepend(G)}else if(w){G='
';r.prepend(G)}else if(this.setImgMarkup(y,r,t),u||f){var k=r.find(".lg-object");this.initPictureFill(k)}(c||w)&&this.LGel.trigger(v,{index:t,src:y,html5Video:C,hasPoster:!!c,isFirstSlide:T}),this.LGel.trigger(p,{index:t}),this.lGalleryOn&&".lg-item"===this.settings.appendSubHtmlTo&&this.addHtml(t)}var A=0;E&&!i(document.body).hasClass("lg-from-hash")&&(A=E),!this.lGalleryOn&&this.zoomFromOrigin&&this.currentImageSize&&(setTimeout((function(){r.removeClass("lg-start-end-progress lg-start-progress").removeAttr("style")}),this.settings.startAnimationDuration+100),r.hasClass("lg-loaded")||setTimeout((function(){if(r.find(".lg-img-wrap").append(a(t,y,"",u,m,n.sources)),u||f){var e=r.find(".lg-object");s.initPictureFill(e)}s.onLgObjectLoad(r,t,E,A,!0,!0);var i=r.find(".lg-object").first();d(i.get())?s.loadContentOnLoad(t,r,A):i.on("load.lg error.lg",(function(){s.loadContentOnLoad(t,r,A)}))}),this.settings.startAnimationDuration+100)),r.addClass("lg-loaded"),this.onLgObjectLoad(r,t,E,A,!1,T),w&&w.html5&&!c&&r.addClass("lg-complete lg-complete_"),this.zoomFromOrigin&&this.currentImageSize||!r.hasClass("lg-complete_")||this.lGalleryOn||setTimeout((function(){r.addClass("lg-complete")}),this.settings.backdropDuration),this.lGalleryOn=!0,!0===e&&(r.hasClass("lg-complete_")?this.preload(t):r.find(".lg-object").first().on("load.lg error.lg",(function(){s.preload(t)})))},s.prototype.loadContentOnLoad=function(t,e,i){var s=this;setTimeout((function(){e.find(".lg-dummy-img").remove(),e.removeClass("lg-first-slide"),s.outer.removeClass("lg-first-slide-loading"),s.isDummyImageRemoved=!0,s.preload(t)}),i+300)},s.prototype.getItemsToBeInsertedToDom=function(t,e,i){var s=this;void 0===i&&(i=0);var n=[],o=Math.max(i,3);o=Math.min(o,this.galleryItems.length);var r="lg-item-"+this.lgId+"-"+e;if(this.galleryItems.length<=3)return this.galleryItems.forEach((function(t,e){n.push("lg-item-"+s.lgId+"-"+e)})),n;if(t<(this.galleryItems.length-1)/2){for(var l=t;l>t-o/2&&l>=0;l--)n.push("lg-item-"+this.lgId+"-"+l);var a=n.length;for(l=0;l')})),this.currentItemsInDom.forEach((function(t){-1===n.indexOf(t)&&i("#"+t).remove()})),n},s.prototype.getPreviousSlideIndex=function(){var t=0;try{var e=this.outer.find(".lg-current").first().attr("id");t=parseInt(e.split("-")[3])||0}catch(e){t=0}return t},s.prototype.setDownloadValue=function(t){if(this.settings.download){var e=this.galleryItems[t];if(!1===e.downloadUrl||"false"===e.downloadUrl)this.outer.addClass("lg-hide-download");else{var i=this.getElementById("lg-download");this.outer.removeClass("lg-hide-download"),i.attr("href",e.downloadUrl||e.src),e.download&&i.attr("download",e.download)}}},s.prototype.makeSlideAnimation=function(t,e,i){var s=this;this.lGalleryOn&&i.addClass("lg-slide-progress"),setTimeout((function(){s.outer.addClass("lg-no-trans"),s.outer.find(".lg-item").removeClass("lg-prev-slide lg-next-slide"),"prev"===t?(e.addClass("lg-prev-slide"),i.addClass("lg-next-slide")):(e.addClass("lg-next-slide"),i.addClass("lg-prev-slide")),setTimeout((function(){s.outer.find(".lg-item").removeClass("lg-current"),e.addClass("lg-current"),s.outer.removeClass("lg-no-trans")}),50)}),this.lGalleryOn?this.settings.slideDelay:0)},s.prototype.slide=function(t,e,i,s){var n=this,r=this.getPreviousSlideIndex();if(this.currentItemsInDom=this.organizeSlideItems(t,r),!this.lGalleryOn||r!==t){var l=this.galleryItems.length;if(!this.lgBusy){this.settings.counter&&this.updateCurrentCounter(t);var a=this.getSlideItem(t),g=this.getSlideItem(r),d=this.galleryItems[t],h=d.__slideVideoInfo;if(this.outer.attr("data-lg-slide-type",this.getSlideType(d)),this.setDownloadValue(t),h){var c=this.mediaContainerPosition,u=c.top,m=c.bottom,p=o(this.items[t],this.outer,u+m,!1,h&&this.settings.videoMaxSize);this.resizeVideoSlide(t,p)}if(this.LGel.trigger(S,{prevIndex:r,index:t,fromTouch:!!e,fromThumb:!!i}),this.lgBusy=!0,clearTimeout(this.hideBarTimeout),this.arrowDisable(t),s||(tr&&(s="next")),e){this.outer.find(".lg-item").removeClass("lg-prev-slide lg-current lg-next-slide");var f=void 0,v=void 0;l>2?(f=t-1,v=t+1,(0===t&&r===l-1||t===l-1&&0===r)&&(v=0,f=l-1)):(f=0,v=1),"prev"===s?this.getSlideItem(v).addClass("lg-next-slide"):this.getSlideItem(f).addClass("lg-prev-slide"),a.addClass("lg-current")}else this.makeSlideAnimation(s,a,g);this.lGalleryOn||this.loadContent(t,!0),setTimeout((function(){n.lGalleryOn&&n.loadContent(t,!0),".lg-item"!==n.settings.appendSubHtmlTo&&n.addHtml(t)}),(this.lGalleryOn?this.settings.speed+50:50)+(e?0:this.settings.slideDelay)),setTimeout((function(){n.lgBusy=!1,g.removeClass("lg-slide-progress"),n.LGel.trigger(T,{prevIndex:r,index:t,fromTouch:e,fromThumb:i})}),(this.lGalleryOn?this.settings.speed+100:100)+(e?0:this.settings.slideDelay))}this.index=t}},s.prototype.updateCurrentCounter=function(t){this.getElementById("lg-counter-current").html(t+1+"")},s.prototype.updateCounterTotal=function(){this.getElementById("lg-counter-all").html(this.galleryItems.length+"")},s.prototype.getSlideType=function(t){return t.__slideVideoInfo?"video":t.iframe?"iframe":"image"},s.prototype.touchMove=function(t,e,i){var s=e.pageX-t.pageX,n=e.pageY-t.pageY,o=!1;if(this.swipeDirection?o=!0:Math.abs(s)>15?(this.swipeDirection="horizontal",o=!0):Math.abs(n)>15&&(this.swipeDirection="vertical",o=!0),o){var r=this.getSlideItem(this.index);if("horizontal"===this.swipeDirection){null==i||i.preventDefault(),this.outer.addClass("lg-dragging"),this.setTranslate(r,s,0);var l=r.get().offsetWidth,a=15*l/100-Math.abs(10*s/100);this.setTranslate(this.outer.find(".lg-prev-slide").first(),-l+s-a,0),this.setTranslate(this.outer.find(".lg-next-slide").first(),l+s+a,0)}else if("vertical"===this.swipeDirection&&this.settings.swipeToClose){null==i||i.preventDefault(),this.$container.addClass("lg-dragging-vertical");var g=1-Math.abs(n)/window.innerHeight;this.$backdrop.css("opacity",g);var d=1-Math.abs(n)/(2*window.innerWidth);this.setTranslate(r,0,n,d,d),Math.abs(n)>100&&this.outer.addClass("lg-hide-items").removeClass("lg-components-open")}}},s.prototype.touchEnd=function(t,e,s){var n,o=this;"lg-slide"!==this.settings.mode&&this.outer.addClass("lg-slide"),setTimeout((function(){o.$container.removeClass("lg-dragging-vertical"),o.outer.removeClass("lg-dragging lg-hide-items").addClass("lg-components-open");var r=!0;if("horizontal"===o.swipeDirection){n=t.pageX-e.pageX;var l=Math.abs(t.pageX-e.pageX);n<0&&l>o.settings.swipeThreshold?(o.goToNextSlide(!0),r=!1):n>0&&l>o.settings.swipeThreshold&&(o.goToPrevSlide(!0),r=!1)}else if("vertical"===o.swipeDirection){if(n=Math.abs(t.pageY-e.pageY),o.settings.closable&&o.settings.swipeToClose&&n>100)return void o.closeGallery();o.$backdrop.css("opacity",1)}if(o.outer.find(".lg-item").removeAttr("style"),r&&Math.abs(t.pageX-e.pageX)<5){var a=i(s.target);o.isPosterElement(a)&&o.LGel.trigger(E)}o.swipeDirection=void 0})),setTimeout((function(){o.outer.hasClass("lg-dragging")||"lg-slide"===o.settings.mode||o.outer.removeClass("lg-slide")}),this.settings.speed+100)},s.prototype.enableSwipe=function(){var t=this,e={},s={},n=!1,o=!1;this.settings.enableSwipe&&(this.$inner.on("touchstart.lg",(function(s){t.dragOrSwipeEnabled=!0;var n=t.getSlideItem(t.index);!i(s.target).hasClass("lg-item")&&!n.get().contains(s.target)||t.outer.hasClass("lg-zoomed")||t.lgBusy||1!==s.targetTouches.length||(o=!0,t.touchAction="swipe",t.manageSwipeClass(),e={pageX:s.targetTouches[0].pageX,pageY:s.targetTouches[0].pageY})})),this.$inner.on("touchmove.lg",(function(i){o&&"swipe"===t.touchAction&&1===i.targetTouches.length&&(s={pageX:i.targetTouches[0].pageX,pageY:i.targetTouches[0].pageY},t.touchMove(e,s,i),n=!0)})),this.$inner.on("touchend.lg",(function(r){if("swipe"===t.touchAction){if(n)n=!1,t.touchEnd(s,e,r);else if(o){var l=i(r.target);t.isPosterElement(l)&&t.LGel.trigger(E)}t.touchAction=void 0,o=!1}})))},s.prototype.enableDrag=function(){var t=this,e={},s={},n=!1,o=!1;this.settings.enableDrag&&(this.outer.on("mousedown.lg",(function(s){t.dragOrSwipeEnabled=!0;var o=t.getSlideItem(t.index);(i(s.target).hasClass("lg-item")||o.get().contains(s.target))&&(t.outer.hasClass("lg-zoomed")||t.lgBusy||(s.preventDefault(),t.lgBusy||(t.manageSwipeClass(),e={pageX:s.pageX,pageY:s.pageY},n=!0,t.outer.get().scrollLeft+=1,t.outer.get().scrollLeft-=1,t.outer.removeClass("lg-grab").addClass("lg-grabbing"),t.LGel.trigger(O))))})),i(window).on("mousemove.lg.global"+this.lgId,(function(i){n&&t.lgOpened&&(o=!0,s={pageX:i.pageX,pageY:i.pageY},t.touchMove(e,s),t.LGel.trigger(L))})),i(window).on("mouseup.lg.global"+this.lgId,(function(r){if(t.lgOpened){var l=i(r.target);o?(o=!1,t.touchEnd(s,e,r),t.LGel.trigger(z)):t.isPosterElement(l)&&t.LGel.trigger(E),n&&(n=!1,t.outer.removeClass("lg-grabbing").addClass("lg-grab"))}})))},s.prototype.triggerPosterClick=function(){var t=this;this.$inner.on("click.lg",(function(e){!t.dragOrSwipeEnabled&&t.isPosterElement(i(e.target))&&t.LGel.trigger(E)}))},s.prototype.manageSwipeClass=function(){var t=this.index+1,e=this.index-1;this.settings.loop&&this.galleryItems.length>2&&(0===this.index?e=this.galleryItems.length-1:this.index===this.galleryItems.length-1&&(t=0)),this.outer.find(".lg-item").removeClass("lg-next-slide lg-prev-slide"),e>-1&&this.getSlideItem(e).addClass("lg-prev-slide"),this.getSlideItem(t).addClass("lg-next-slide")},s.prototype.goToNextSlide=function(t){var e=this,i=this.settings.loop;t&&this.galleryItems.length<3&&(i=!1),this.lgBusy||(this.index+10?(this.index--,this.LGel.trigger(G,{index:this.index,fromTouch:t}),this.slide(this.index,!!t,!1,"prev")):i?(this.index=this.galleryItems.length-1,this.LGel.trigger(G,{index:this.index,fromTouch:t}),this.slide(this.index,!!t,!1,"prev")):this.settings.slideEndAnimation&&!t&&(this.outer.addClass("lg-left-end"),setTimeout((function(){e.outer.removeClass("lg-left-end")}),400)))},s.prototype.keyPress=function(){var t=this;i(window).on("keydown.lg.global"+this.lgId,(function(e){t.lgOpened&&!0===t.settings.escKey&&27===e.keyCode&&(e.preventDefault(),t.settings.allowMediaOverlap&&t.outer.hasClass("lg-can-toggle")&&t.outer.hasClass("lg-components-open")?t.outer.removeClass("lg-components-open"):t.closeGallery()),t.lgOpened&&t.galleryItems.length>1&&(37===e.keyCode&&(e.preventDefault(),t.goToPrevSlide()),39===e.keyCode&&(e.preventDefault(),t.goToNextSlide()))}))},s.prototype.arrow=function(){var t=this;this.getElementById("lg-prev").on("click.lg",(function(){t.goToPrevSlide()})),this.getElementById("lg-next").on("click.lg",(function(){t.goToNextSlide()}))},s.prototype.arrowDisable=function(t){if(!this.settings.loop&&this.settings.hideControlOnEnd){var e=this.getElementById("lg-prev"),i=this.getElementById("lg-next");t+1===this.galleryItems.length?i.attr("disabled","disabled").addClass("disabled"):i.removeAttr("disabled").removeClass("disabled"),0===t?e.attr("disabled","disabled").addClass("disabled"):e.removeAttr("disabled").removeClass("disabled")}},s.prototype.setTranslate=function(t,e,i,s,n){void 0===s&&(s=1),void 0===n&&(n=1),t.css("transform","translate3d("+e+"px, "+i+"px, 0px) scale3d("+s+", "+n+", 1)")},s.prototype.mousewheel=function(){var t=this;this.outer.on("mousewheel.lg",(function(e){!e.deltaY||t.galleryItems.length<2||(e.deltaY>0?t.goToPrevSlide():t.goToNextSlide(),e.preventDefault())}))},s.prototype.isSlideElement=function(t){return t.hasClass("lg-outer")||t.hasClass("lg-item")||t.hasClass("lg-img-wrap")},s.prototype.isPosterElement=function(t){var e=this.getSlideItem(this.index).find(".lg-video-play-button").get();return t.hasClass("lg-video-poster")||t.hasClass("lg-video-play-button")||e&&e.contains(t.get())},s.prototype.toggleMaximize=function(){var t=this;this.getElementById("lg-maximize").on("click.lg",(function(){t.$container.toggleClass("lg-inline"),t.refreshOnResize()}))},s.prototype.invalidateItems=function(){for(var t=0;t " + imgContent + ""; $currentSlide.prepend(imgMarkup); }; - LightGallery.prototype.onLgObjectLoad = function ($el, index, delay, speed, dummyImageLoaded) { + LightGallery.prototype.onLgObjectLoad = function ($el, index, delay, speed, dummyImageLoaded, isFirstSlide) { var _this = this; if (dummyImageLoaded) { this.LGel.trigger(lGEvents.slideItemLoad, { index: index, delay: delay || 0, + isFirstSlide: isFirstSlide, }); } $el.find('.lg-object') .first() .on('load.lg', function () { - _this.handleLgObjectLoad($el, index, delay, speed, dummyImageLoaded); + _this.handleLgObjectLoad($el, index, delay, speed, dummyImageLoaded, isFirstSlide); }); setTimeout(function () { $el.find('.lg-object') @@ -1451,7 +1453,7 @@ }); }, speed); }; - LightGallery.prototype.handleLgObjectLoad = function ($el, index, delay, speed, dummyImageLoaded) { + LightGallery.prototype.handleLgObjectLoad = function ($el, index, delay, speed, dummyImageLoaded, isFirstSlide) { var _this = this; setTimeout(function () { $el.addClass('lg-complete lg-complete_'); @@ -1459,6 +1461,7 @@ _this.LGel.trigger(lGEvents.slideItemLoad, { index: index, delay: delay || 0, + isFirstSlide: isFirstSlide, }); } }, speed); @@ -1485,7 +1488,7 @@ return; } } - var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)/i); + var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)([\&|?][\S]*)*/i); var vimeo = src.match(/\/\/(?:www\.)?(?:player\.)?vimeo.com\/(?:video\/)?([0-9a-z\-_]+)/i); var wistia = src.match(/https?:\/\/(.+)?(wistia\.com|wi\.st)\/(medias|embed)\/([0-9a-z\-_]+)(.*)/); if (youtube) { @@ -1532,10 +1535,21 @@ var videoInfo = currentGalleryItem.__slideVideoInfo; var lgVideoStyle = ''; var iframe = !!currentGalleryItem.iframe; + var isFirstSlide = !this.lGalleryOn; + // delay for adding complete class. it is 0 except first time. + var delay = 0; + if (isFirstSlide) { + if (this.zoomFromOrigin && this.currentImageSize) { + delay = this.settings.startAnimationDuration + 10; + } + else { + delay = this.settings.backdropDuration + 10; + } + } if (!$currentSlide.hasClass('lg-loaded')) { if (videoInfo) { var _a = this.mediaContainerPosition, top_2 = _a.top, bottom = _a.bottom; - var videoSize = utils.getSize(this.items[index], this.outer, top_2 + bottom, videoInfo && this.settings.videoMaxSize); + var videoSize = utils.getSize(this.items[index], this.outer, top_2 + bottom, false, videoInfo && this.settings.videoMaxSize); lgVideoStyle = this.getVideoContStyle(videoSize); } if (iframe) { @@ -1544,8 +1558,7 @@ } else if (poster) { var dummyImg = ''; - var isFirstSlide_1 = !this.lGalleryOn; - var hasStartAnimation = !this.lGalleryOn && + var hasStartAnimation = isFirstSlide && this.zoomFromOrigin && this.currentImageSize; if (hasStartAnimation) { @@ -1553,28 +1566,10 @@ } var markup = utils.getVideoPosterMarkup(poster, dummyImg || '', lgVideoStyle, videoInfo); $currentSlide.prepend(markup); - var delay_1 = (hasStartAnimation - ? this.settings.startAnimationDuration - : this.settings.backdropDuration) + 100; - setTimeout(function () { - _this.LGel.trigger(lGEvents.hasVideo, { - index: index, - src: src, - html5Video: _html5Video, - hasPoster: true, - isFirstSlide: isFirstSlide_1, - }); - }, delay_1); } else if (videoInfo) { var markup = "
"; $currentSlide.prepend(markup); - this.LGel.trigger(lGEvents.hasVideo, { - index: index, - src: src, - html5Video: _html5Video, - hasPoster: false, - }); } else { this.setImgMarkup(src, $currentSlide, index); @@ -1583,6 +1578,15 @@ this.initPictureFill($img); } } + if (poster || videoInfo) { + this.LGel.trigger(lGEvents.hasVideo, { + index: index, + src: src, + html5Video: _html5Video, + hasPoster: !!poster, + isFirstSlide: isFirstSlide, + }); + } this.LGel.trigger(lGEvents.afterAppendSlide, { index: index }); if (this.lGalleryOn && this.settings.appendSubHtmlTo === '.lg-item') { @@ -1591,16 +1595,6 @@ } // For first time add some delay for displaying the start animation. var _speed = 0; - // delay for adding complete class. it is 0 except first time. - var delay = 0; - if (!this.lGalleryOn) { - if (this.zoomFromOrigin && this.currentImageSize) { - delay = this.settings.startAnimationDuration + 10; - } - else { - delay = this.settings.backdropDuration + 10; - } - } // Do not change the delay value because it is required for zoom plugin. // If gallery opened from direct url (hash) speed value should be 0 if (delay && !$LG(document.body).hasClass('lg-from-hash')) { @@ -1622,7 +1616,7 @@ var $img = $currentSlide.find('.lg-object'); _this.initPictureFill($img); } - _this.onLgObjectLoad($currentSlide, index, delay, _speed, true); + _this.onLgObjectLoad($currentSlide, index, delay, _speed, true, true); var mediaObject = $currentSlide .find('.lg-object') .first(); @@ -1639,7 +1633,7 @@ } // SLide content has been added to dom $currentSlide.addClass('lg-loaded'); - this.onLgObjectLoad($currentSlide, index, delay, _speed, false); + this.onLgObjectLoad($currentSlide, index, delay, _speed, false, isFirstSlide); // @todo check load state for html5 videos if (videoInfo && videoInfo.html5 && !poster) { $currentSlide.addClass('lg-complete lg-complete_'); @@ -1840,7 +1834,7 @@ this.setDownloadValue(index); if (videoInfo) { var _a = this.mediaContainerPosition, top_3 = _a.top, bottom = _a.bottom; - var videoSize = utils.getSize(this.items[index], this.outer, top_3 + bottom, videoInfo && this.settings.videoMaxSize); + var videoSize = utils.getSize(this.items[index], this.outer, top_3 + bottom, false, videoInfo && this.settings.videoMaxSize); this.resizeVideoSlide(index, videoSize); } this.LGel.trigger(lGEvents.beforeSlide, { @@ -2446,8 +2440,8 @@ var transform; if (this.zoomFromOrigin && currentItem) { var _a = this.mediaContainerPosition, top_4 = _a.top, bottom = _a.bottom; - var imageSize = utils.getSize(currentItem, this.outer, top_4 + bottom, this.galleryItems[this.index].__slideVideoInfo && - this.settings.videoMaxSize); + var _b = this.galleryItems[this.index], __slideVideoInfo = _b.__slideVideoInfo, poster = _b.poster; + var imageSize = utils.getSize(currentItem, this.outer, top_4 + bottom, __slideVideoInfo && !poster, __slideVideoInfo && poster && this.settings.videoMaxSize); transform = utils.getTransform(currentItem, this.outer, top_4, bottom, imageSize); } if (this.zoomFromOrigin && transform) { diff --git a/dist/plugins/autoplay/lg-autoplay.es5.js b/dist/plugins/autoplay/lg-autoplay.es5.js index 0dd46c385..53f549f31 100644 --- a/dist/plugins/autoplay/lg-autoplay.es5.js +++ b/dist/plugins/autoplay/lg-autoplay.es5.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/autoplay/lg-autoplay.min.js b/dist/plugins/autoplay/lg-autoplay.min.js index a0413e40e..ca25053a3 100644 --- a/dist/plugins/autoplay/lg-autoplay.min.js +++ b/dist/plugins/autoplay/lg-autoplay.min.js @@ -1,5 +1,5 @@ /** - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/autoplay/lg-autoplay.umd.js b/dist/plugins/autoplay/lg-autoplay.umd.js index 23f20dd64..0b59e2c8d 100644 --- a/dist/plugins/autoplay/lg-autoplay.umd.js +++ b/dist/plugins/autoplay/lg-autoplay.umd.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/comment/lg-comment.es5.js b/dist/plugins/comment/lg-comment.es5.js index 3e7c7d702..60dd6bd56 100644 --- a/dist/plugins/comment/lg-comment.es5.js +++ b/dist/plugins/comment/lg-comment.es5.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/comment/lg-comment.min.js b/dist/plugins/comment/lg-comment.min.js index 28f5c34bf..b033987e4 100644 --- a/dist/plugins/comment/lg-comment.min.js +++ b/dist/plugins/comment/lg-comment.min.js @@ -1,5 +1,5 @@ /** - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/comment/lg-comment.umd.js b/dist/plugins/comment/lg-comment.umd.js index 0acf3e234..654cd2a40 100644 --- a/dist/plugins/comment/lg-comment.umd.js +++ b/dist/plugins/comment/lg-comment.umd.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/fullscreen/lg-fullscreen.es5.js b/dist/plugins/fullscreen/lg-fullscreen.es5.js index d91d3260e..652c033f5 100644 --- a/dist/plugins/fullscreen/lg-fullscreen.es5.js +++ b/dist/plugins/fullscreen/lg-fullscreen.es5.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/fullscreen/lg-fullscreen.min.js b/dist/plugins/fullscreen/lg-fullscreen.min.js index f0ada53f3..1d9095302 100644 --- a/dist/plugins/fullscreen/lg-fullscreen.min.js +++ b/dist/plugins/fullscreen/lg-fullscreen.min.js @@ -1,5 +1,5 @@ /** - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/fullscreen/lg-fullscreen.umd.js b/dist/plugins/fullscreen/lg-fullscreen.umd.js index da085fbd6..c99b8e07e 100644 --- a/dist/plugins/fullscreen/lg-fullscreen.umd.js +++ b/dist/plugins/fullscreen/lg-fullscreen.umd.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/hash/lg-hash.es5.js b/dist/plugins/hash/lg-hash.es5.js index 98b3bd957..902836f59 100644 --- a/dist/plugins/hash/lg-hash.es5.js +++ b/dist/plugins/hash/lg-hash.es5.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/hash/lg-hash.min.js b/dist/plugins/hash/lg-hash.min.js index d7a9f6248..4311296e4 100644 --- a/dist/plugins/hash/lg-hash.min.js +++ b/dist/plugins/hash/lg-hash.min.js @@ -1,5 +1,5 @@ /** - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/hash/lg-hash.umd.js b/dist/plugins/hash/lg-hash.umd.js index 3a9bd7bfe..2ff480b0f 100644 --- a/dist/plugins/hash/lg-hash.umd.js +++ b/dist/plugins/hash/lg-hash.umd.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/mediumZoom/lg-medium-zoom.es5.js b/dist/plugins/mediumZoom/lg-medium-zoom.es5.js index 421ba90e3..da81986ba 100644 --- a/dist/plugins/mediumZoom/lg-medium-zoom.es5.js +++ b/dist/plugins/mediumZoom/lg-medium-zoom.es5.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/mediumZoom/lg-medium-zoom.min.js b/dist/plugins/mediumZoom/lg-medium-zoom.min.js index 2439bec08..296448bec 100644 --- a/dist/plugins/mediumZoom/lg-medium-zoom.min.js +++ b/dist/plugins/mediumZoom/lg-medium-zoom.min.js @@ -1,5 +1,5 @@ /** - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/mediumZoom/lg-medium-zoom.umd.js b/dist/plugins/mediumZoom/lg-medium-zoom.umd.js index fbbdba463..aa2456225 100644 --- a/dist/plugins/mediumZoom/lg-medium-zoom.umd.js +++ b/dist/plugins/mediumZoom/lg-medium-zoom.umd.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/pager/lg-pager.es5.js b/dist/plugins/pager/lg-pager.es5.js index 5b691bac5..51eeaea3c 100644 --- a/dist/plugins/pager/lg-pager.es5.js +++ b/dist/plugins/pager/lg-pager.es5.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/pager/lg-pager.min.js b/dist/plugins/pager/lg-pager.min.js index 6bbedb729..28badedf2 100644 --- a/dist/plugins/pager/lg-pager.min.js +++ b/dist/plugins/pager/lg-pager.min.js @@ -1,5 +1,5 @@ /** - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/pager/lg-pager.umd.js b/dist/plugins/pager/lg-pager.umd.js index 119a642c3..260253795 100644 --- a/dist/plugins/pager/lg-pager.umd.js +++ b/dist/plugins/pager/lg-pager.umd.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/relativeCaption/lg-relative-caption.es5.js b/dist/plugins/relativeCaption/lg-relative-caption.es5.js index 87bc3379e..7e6066a94 100644 --- a/dist/plugins/relativeCaption/lg-relative-caption.es5.js +++ b/dist/plugins/relativeCaption/lg-relative-caption.es5.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/relativeCaption/lg-relative-caption.min.js b/dist/plugins/relativeCaption/lg-relative-caption.min.js index ba9550b46..c7e0e4910 100644 --- a/dist/plugins/relativeCaption/lg-relative-caption.min.js +++ b/dist/plugins/relativeCaption/lg-relative-caption.min.js @@ -1,5 +1,5 @@ /** - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/relativeCaption/lg-relative-caption.umd.js b/dist/plugins/relativeCaption/lg-relative-caption.umd.js index e87b3de00..fc9758e8b 100644 --- a/dist/plugins/relativeCaption/lg-relative-caption.umd.js +++ b/dist/plugins/relativeCaption/lg-relative-caption.umd.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/rotate/lg-rotate.es5.js b/dist/plugins/rotate/lg-rotate.es5.js index bb54a389a..4e93e56ea 100644 --- a/dist/plugins/rotate/lg-rotate.es5.js +++ b/dist/plugins/rotate/lg-rotate.es5.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/rotate/lg-rotate.min.js b/dist/plugins/rotate/lg-rotate.min.js index 3ee123da1..0cd782588 100644 --- a/dist/plugins/rotate/lg-rotate.min.js +++ b/dist/plugins/rotate/lg-rotate.min.js @@ -1,5 +1,5 @@ /** - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/rotate/lg-rotate.umd.js b/dist/plugins/rotate/lg-rotate.umd.js index 7609e7608..1f2318df2 100644 --- a/dist/plugins/rotate/lg-rotate.umd.js +++ b/dist/plugins/rotate/lg-rotate.umd.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/share/lg-share.es5.js b/dist/plugins/share/lg-share.es5.js index 015fcf5f6..37c91b981 100644 --- a/dist/plugins/share/lg-share.es5.js +++ b/dist/plugins/share/lg-share.es5.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/share/lg-share.min.js b/dist/plugins/share/lg-share.min.js index 699b9628f..c03e1d268 100644 --- a/dist/plugins/share/lg-share.min.js +++ b/dist/plugins/share/lg-share.min.js @@ -1,5 +1,5 @@ /** - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/share/lg-share.umd.js b/dist/plugins/share/lg-share.umd.js index 73fd456e7..0735ece98 100644 --- a/dist/plugins/share/lg-share.umd.js +++ b/dist/plugins/share/lg-share.umd.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/thumbnail/lg-thumbnail.es5.js b/dist/plugins/thumbnail/lg-thumbnail.es5.js index 6f5d47df0..30baf65bf 100644 --- a/dist/plugins/thumbnail/lg-thumbnail.es5.js +++ b/dist/plugins/thumbnail/lg-thumbnail.es5.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/thumbnail/lg-thumbnail.min.js b/dist/plugins/thumbnail/lg-thumbnail.min.js index 8e5ae7664..0bd4a8523 100644 --- a/dist/plugins/thumbnail/lg-thumbnail.min.js +++ b/dist/plugins/thumbnail/lg-thumbnail.min.js @@ -1,5 +1,5 @@ /** - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/thumbnail/lg-thumbnail.umd.js b/dist/plugins/thumbnail/lg-thumbnail.umd.js index bb6527c39..d59ddbb1f 100644 --- a/dist/plugins/thumbnail/lg-thumbnail.umd.js +++ b/dist/plugins/thumbnail/lg-thumbnail.umd.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/video/lg-video.es5.js b/dist/plugins/video/lg-video.es5.js index 243c47309..47009cecc 100644 --- a/dist/plugins/video/lg-video.es5.js +++ b/dist/plugins/video/lg-video.es5.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 @@ -91,6 +91,7 @@ var lGEvents = { * @ref Youtube * https://developers.google.com/youtube/player_parameters#enablejsapi * https://developers.google.com/youtube/iframe_api_reference + * https://developer.chrome.com/blog/autoplay/#iframe-delegation * */ function param(obj) { @@ -119,11 +120,38 @@ var Video = /** @class */ (function () { var $el = _this.core.getSlideItem(_this.core.index); _this.loadVideoOnPosterClick($el); }); + this.core.LGel.on(lGEvents.slideItemLoad + ".video", this.onSlideItemLoad.bind(this)); // @desc fired immediately before each slide transition. this.core.LGel.on(lGEvents.beforeSlide + ".video", this.onBeforeSlide.bind(this)); // @desc fired immediately after each slide transition. this.core.LGel.on(lGEvents.afterSlide + ".video", this.onAfterSlide.bind(this)); }; + /** + * @desc Event triggered when a slide is completely loaded + * + * @param {Event} event - lightGalley custom event + */ + Video.prototype.onSlideItemLoad = function (event) { + var _this = this; + var _a = event.detail, isFirstSlide = _a.isFirstSlide, index = _a.index; + // Should check the active slide as well as user may have moved to different slide before the first slide is loaded + if (this.settings.autoplayFirstVideo && + isFirstSlide && + index === this.core.index) { + // Delay is just for the transition effect on video load + setTimeout(function () { + var currentGalleryItem = _this.core.galleryItems[index]; + var poster = currentGalleryItem.poster; + if (poster) { + var $slide = _this.core.getSlideItem(index); + _this.loadVideoOnPosterClick($slide); + } + else { + _this.playVideo(index); + } + }, 200); + } + }; /** * @desc Event triggered when video url or poster found * Append video HTML is poster is not given @@ -132,7 +160,7 @@ var Video = /** @class */ (function () { * @param {Event} event - Javascript Event object. */ Video.prototype.onHasVideo = function (event) { - var _a = event.detail, index = _a.index, src = _a.src, html5Video = _a.html5Video, hasPoster = _a.hasPoster, isFirstSlide = _a.isFirstSlide; + var _a = event.detail, index = _a.index, src = _a.src, html5Video = _a.html5Video, hasPoster = _a.hasPoster; if (!hasPoster) { // All functions are called separately if poster exist in loadVideoOnPosterClick function this.appendVideos(this.core.getSlideItem(index), { @@ -144,15 +172,6 @@ var Video = /** @class */ (function () { // Automatically navigate to next slide once video reaches the end. this.gotoNextSlideOnVideoEnd(src, index); } - if (this.settings.autoplayFirstVideo && isFirstSlide) { - if (hasPoster) { - var $slide = this.core.getSlideItem(index); - this.loadVideoOnPosterClick($slide); - } - else { - this.playVideo(index); - } - } }; /** * @desc fired immediately before each slide transition. @@ -164,8 +183,10 @@ var Video = /** @class */ (function () { * @param {number} index - Current index of the slide */ Video.prototype.onBeforeSlide = function (event) { - var _a = event.detail, prevIndex = _a.prevIndex; _a.index; - this.pauseVideo(prevIndex); + if (this.core.lGalleryOn) { + var prevIndex = event.detail.prevIndex; + this.pauseVideo(prevIndex); + } }; /** * @desc fired immediately after each slide transition. @@ -174,11 +195,13 @@ var Video = /** @class */ (function () { * @param {Event} event - Javascript Event object. * @param {number} prevIndex - Previous index of the slide. * @param {number} index - Current index of the slide + * @todo should check on onSlideLoad as well if video is not loaded on after slide */ Video.prototype.onAfterSlide = function (event) { var _this = this; - var index = event.detail.index; - if (this.settings.autoplayVideoOnSlide && this.core.lGalleryOn) { + var _a = event.detail, index = _a.index, prevIndex = _a.prevIndex; + // Do not call on first slide + if (this.settings.autoplayVideoOnSlide && index !== prevIndex) { setTimeout(function () { var $slide = _this.core.getSlideItem(index); if (!$slide.hasClass('lg-video-loaded')) { @@ -214,7 +237,10 @@ var Video = /** @class */ (function () { var commonIframeProps = "allowtransparency=\"true\"\n frameborder=\"0\"\n scrolling=\"no\"\n allowfullscreen\n mozallowfullscreen\n webkitallowfullscreen\n oallowfullscreen\n msallowfullscreen"; if (videoInfo.youtube) { var videoId = 'lg-youtube' + index; - var youTubePlayerParams = "?wmode=opaque&autoplay=0&enablejsapi=1"; + var slideUrlParams = videoInfo.youtube[2] + ? videoInfo.youtube[2] + '&' + : ''; + var youTubePlayerParams = "?" + slideUrlParams + "wmode=opaque&autoplay=0&mute=1&enablejsapi=1"; var playerParams = youTubePlayerParams + (this.settings.youTubePlayerParams ? '&' + param(this.settings.youTubePlayerParams) diff --git a/dist/plugins/video/lg-video.min.js b/dist/plugins/video/lg-video.min.js index db303da9f..2f9e61346 100644 --- a/dist/plugins/video/lg-video.min.js +++ b/dist/plugins/video/lg-video.min.js @@ -1,8 +1,8 @@ /** - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 */ -!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(e="undefined"!=typeof globalThis?globalThis:e||self).lgVideo=o()}(this,(function(){"use strict";var e=function(){return(e=Object.assign||function(e){for(var o,i=1,t=arguments.length;i"}else if(l.vimeo){c="lg-vimeo"+i,f=n(this.settings.vimeoPlayerParams);s='"}else if(l.wistia){var u="lg-wistia"+i;f=n(this.settings.wistiaPlayerParams);s='"}else if(l.html5){for(var h="",g=0;g';if(t.tracks){var y=function(e){var o="",i=t.tracks[e];Object.keys(i||{}).forEach((function(e){o+=e+'="'+i[e]+'" '})),h+=""};for(g=0;g\n "+h+"\n Your browser does not support HTML5 video.\n "}return s},r.prototype.appendVideos=function(e,o){var i,t=this.getVideoHtml(o.src,o.addClass,o.index,o.html5Video);e.find(".lg-video-cont").append(t);var s=e.find(".lg-video-object").first();if(o.html5Video&&s.on("mousedown.lg.video",(function(e){e.stopPropagation()})),this.settings.videojs&&(null===(i=this.core.galleryItems[o.index].__slideVideoInfo)||void 0===i?void 0:i.html5))try{return videojs(s.get(),this.settings.videojsOptions)}catch(e){console.error("lightGallery:- Make sure you have included videojs")}},r.prototype.gotoNextSlideOnVideoEnd=function(e,o){var i=this,t=this.core.getSlideItem(o).find(".lg-video-object").first(),s=this.core.galleryItems[o].__slideVideoInfo||{};if(this.settings.gotoNextSlideOnVideoEnd)if(s.html5)t.on("ended",(function(){i.core.goToNextSlide()}));else if(s.vimeo)try{new Vimeo.Player(t.get()).on("ended",(function(){i.core.goToNextSlide()}))}catch(e){console.error("lightGallery:- Make sure you have included //github.com/vimeo/player.js")}else if(s.wistia)try{window._wq=window._wq||[],window._wq.push({id:t.attr("id"),onReady:function(e){e.bind("end",(function(){i.core.goToNextSlide()}))}})}catch(e){console.error("lightGallery:- Make sure you have included //fast.wistia.com/assets/external/E-v1.js")}},r.prototype.controlVideo=function(e,o){var i=this.core.getSlideItem(e).find(".lg-video-object").first(),t=this.core.galleryItems[e].__slideVideoInfo||{};if(i.get())if(t.youtube)try{i.get().contentWindow.postMessage('{"event":"command","func":"'+o+'Video","args":""}',"*")}catch(e){console.error("lightGallery:- "+e)}else if(t.vimeo)try{new Vimeo.Player(i.get())[o]()}catch(e){console.error("lightGallery:- Make sure you have included //github.com/vimeo/player.js")}else if(t.html5)if(this.settings.videojs)try{videojs(i.get())[o]()}catch(e){console.error("lightGallery:- Make sure you have included videojs")}else i.get()[o]();else if(t.wistia)try{window._wq=window._wq||[],window._wq.push({id:i.attr("id"),onReady:function(e){e[o]()}})}catch(e){console.error("lightGallery:- Make sure you have included //fast.wistia.com/assets/external/E-v1.js")}},r.prototype.loadVideoOnPosterClick=function(e){var o=this;if(!e.hasClass("lg-video-loaded"))if(e.hasClass("lg-has-video"))this.playVideo(this.core.index);else{e.addClass("lg-has-video");var i=void 0,t=this.core.galleryItems[this.core.index].src,s=this.core.galleryItems[this.core.index].video;s&&(i="string"==typeof s?JSON.parse(s):s);var l=this.appendVideos(e,{src:t,addClass:"",index:this.core.index,html5Video:i});this.gotoNextSlideOnVideoEnd(t,this.core.index);var n=e.find(".lg-object").first().get();e.find(".lg-video-cont").first().append(n),e.addClass("lg-video-loading"),l&&l.ready((function(){l.on("loadedmetadata",(function(){o.onVideoLoadAfterPosterClick(e,o.core.index)}))})),e.find(".lg-video-object").first().on("load.lg error.lg loadeddata.lg",(function(){setTimeout((function(){o.onVideoLoadAfterPosterClick(e,o.core.index)}),50)}))}},r.prototype.onVideoLoadAfterPosterClick=function(e,o){e.addClass("lg-video-loaded"),this.playVideo(o)},r.prototype.destroy=function(){this.core.LGel.off(".lg.video"),this.core.LGel.off(".video")},r}()})); +!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(e="undefined"!=typeof globalThis?globalThis:e||self).lgVideo=o()}(this,(function(){"use strict";var e=function(){return(e=Object.assign||function(e){for(var o,i=1,t=arguments.length;i"}else if(n.vimeo){c="lg-vimeo"+i,u=r(this.settings.vimeoPlayerParams);s='"}else if(n.wistia){var f="lg-wistia"+i;u=r(this.settings.wistiaPlayerParams);s='"}else if(n.html5){for(var h="",g=0;g';if(t.tracks){var y=function(e){var o="",i=t.tracks[e];Object.keys(i||{}).forEach((function(e){o+=e+'="'+i[e]+'" '})),h+=""};for(g=0;g\n "+h+"\n Your browser does not support HTML5 video.\n "}return s},d.prototype.appendVideos=function(e,o){var i,t=this.getVideoHtml(o.src,o.addClass,o.index,o.html5Video);e.find(".lg-video-cont").append(t);var s=e.find(".lg-video-object").first();if(o.html5Video&&s.on("mousedown.lg.video",(function(e){e.stopPropagation()})),this.settings.videojs&&(null===(i=this.core.galleryItems[o.index].__slideVideoInfo)||void 0===i?void 0:i.html5))try{return videojs(s.get(),this.settings.videojsOptions)}catch(e){console.error("lightGallery:- Make sure you have included videojs")}},d.prototype.gotoNextSlideOnVideoEnd=function(e,o){var i=this,t=this.core.getSlideItem(o).find(".lg-video-object").first(),s=this.core.galleryItems[o].__slideVideoInfo||{};if(this.settings.gotoNextSlideOnVideoEnd)if(s.html5)t.on("ended",(function(){i.core.goToNextSlide()}));else if(s.vimeo)try{new Vimeo.Player(t.get()).on("ended",(function(){i.core.goToNextSlide()}))}catch(e){console.error("lightGallery:- Make sure you have included //github.com/vimeo/player.js")}else if(s.wistia)try{window._wq=window._wq||[],window._wq.push({id:t.attr("id"),onReady:function(e){e.bind("end",(function(){i.core.goToNextSlide()}))}})}catch(e){console.error("lightGallery:- Make sure you have included //fast.wistia.com/assets/external/E-v1.js")}},d.prototype.controlVideo=function(e,o){var i=this.core.getSlideItem(e).find(".lg-video-object").first(),t=this.core.galleryItems[e].__slideVideoInfo||{};if(i.get())if(t.youtube)try{i.get().contentWindow.postMessage('{"event":"command","func":"'+o+'Video","args":""}',"*")}catch(e){console.error("lightGallery:- "+e)}else if(t.vimeo)try{new Vimeo.Player(i.get())[o]()}catch(e){console.error("lightGallery:- Make sure you have included //github.com/vimeo/player.js")}else if(t.html5)if(this.settings.videojs)try{videojs(i.get())[o]()}catch(e){console.error("lightGallery:- Make sure you have included videojs")}else i.get()[o]();else if(t.wistia)try{window._wq=window._wq||[],window._wq.push({id:i.attr("id"),onReady:function(e){e[o]()}})}catch(e){console.error("lightGallery:- Make sure you have included //fast.wistia.com/assets/external/E-v1.js")}},d.prototype.loadVideoOnPosterClick=function(e){var o=this;if(!e.hasClass("lg-video-loaded"))if(e.hasClass("lg-has-video"))this.playVideo(this.core.index);else{e.addClass("lg-has-video");var i=void 0,t=this.core.galleryItems[this.core.index].src,s=this.core.galleryItems[this.core.index].video;s&&(i="string"==typeof s?JSON.parse(s):s);var n=this.appendVideos(e,{src:t,addClass:"",index:this.core.index,html5Video:i});this.gotoNextSlideOnVideoEnd(t,this.core.index);var l=e.find(".lg-object").first().get();e.find(".lg-video-cont").first().append(l),e.addClass("lg-video-loading"),n&&n.ready((function(){n.on("loadedmetadata",(function(){o.onVideoLoadAfterPosterClick(e,o.core.index)}))})),e.find(".lg-video-object").first().on("load.lg error.lg loadeddata.lg",(function(){setTimeout((function(){o.onVideoLoadAfterPosterClick(e,o.core.index)}),50)}))}},d.prototype.onVideoLoadAfterPosterClick=function(e,o){e.addClass("lg-video-loaded"),this.playVideo(o)},d.prototype.destroy=function(){this.core.LGel.off(".lg.video"),this.core.LGel.off(".video")},d}()})); diff --git a/dist/plugins/video/lg-video.umd.js b/dist/plugins/video/lg-video.umd.js index 68b00802f..b593c17d6 100644 --- a/dist/plugins/video/lg-video.umd.js +++ b/dist/plugins/video/lg-video.umd.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 @@ -97,6 +97,7 @@ * @ref Youtube * https://developers.google.com/youtube/player_parameters#enablejsapi * https://developers.google.com/youtube/iframe_api_reference + * https://developer.chrome.com/blog/autoplay/#iframe-delegation * */ function param(obj) { @@ -125,11 +126,38 @@ var $el = _this.core.getSlideItem(_this.core.index); _this.loadVideoOnPosterClick($el); }); + this.core.LGel.on(lGEvents.slideItemLoad + ".video", this.onSlideItemLoad.bind(this)); // @desc fired immediately before each slide transition. this.core.LGel.on(lGEvents.beforeSlide + ".video", this.onBeforeSlide.bind(this)); // @desc fired immediately after each slide transition. this.core.LGel.on(lGEvents.afterSlide + ".video", this.onAfterSlide.bind(this)); }; + /** + * @desc Event triggered when a slide is completely loaded + * + * @param {Event} event - lightGalley custom event + */ + Video.prototype.onSlideItemLoad = function (event) { + var _this = this; + var _a = event.detail, isFirstSlide = _a.isFirstSlide, index = _a.index; + // Should check the active slide as well as user may have moved to different slide before the first slide is loaded + if (this.settings.autoplayFirstVideo && + isFirstSlide && + index === this.core.index) { + // Delay is just for the transition effect on video load + setTimeout(function () { + var currentGalleryItem = _this.core.galleryItems[index]; + var poster = currentGalleryItem.poster; + if (poster) { + var $slide = _this.core.getSlideItem(index); + _this.loadVideoOnPosterClick($slide); + } + else { + _this.playVideo(index); + } + }, 200); + } + }; /** * @desc Event triggered when video url or poster found * Append video HTML is poster is not given @@ -138,7 +166,7 @@ * @param {Event} event - Javascript Event object. */ Video.prototype.onHasVideo = function (event) { - var _a = event.detail, index = _a.index, src = _a.src, html5Video = _a.html5Video, hasPoster = _a.hasPoster, isFirstSlide = _a.isFirstSlide; + var _a = event.detail, index = _a.index, src = _a.src, html5Video = _a.html5Video, hasPoster = _a.hasPoster; if (!hasPoster) { // All functions are called separately if poster exist in loadVideoOnPosterClick function this.appendVideos(this.core.getSlideItem(index), { @@ -150,15 +178,6 @@ // Automatically navigate to next slide once video reaches the end. this.gotoNextSlideOnVideoEnd(src, index); } - if (this.settings.autoplayFirstVideo && isFirstSlide) { - if (hasPoster) { - var $slide = this.core.getSlideItem(index); - this.loadVideoOnPosterClick($slide); - } - else { - this.playVideo(index); - } - } }; /** * @desc fired immediately before each slide transition. @@ -170,8 +189,10 @@ * @param {number} index - Current index of the slide */ Video.prototype.onBeforeSlide = function (event) { - var _a = event.detail, prevIndex = _a.prevIndex; _a.index; - this.pauseVideo(prevIndex); + if (this.core.lGalleryOn) { + var prevIndex = event.detail.prevIndex; + this.pauseVideo(prevIndex); + } }; /** * @desc fired immediately after each slide transition. @@ -180,11 +201,13 @@ * @param {Event} event - Javascript Event object. * @param {number} prevIndex - Previous index of the slide. * @param {number} index - Current index of the slide + * @todo should check on onSlideLoad as well if video is not loaded on after slide */ Video.prototype.onAfterSlide = function (event) { var _this = this; - var index = event.detail.index; - if (this.settings.autoplayVideoOnSlide && this.core.lGalleryOn) { + var _a = event.detail, index = _a.index, prevIndex = _a.prevIndex; + // Do not call on first slide + if (this.settings.autoplayVideoOnSlide && index !== prevIndex) { setTimeout(function () { var $slide = _this.core.getSlideItem(index); if (!$slide.hasClass('lg-video-loaded')) { @@ -220,7 +243,10 @@ var commonIframeProps = "allowtransparency=\"true\"\n frameborder=\"0\"\n scrolling=\"no\"\n allowfullscreen\n mozallowfullscreen\n webkitallowfullscreen\n oallowfullscreen\n msallowfullscreen"; if (videoInfo.youtube) { var videoId = 'lg-youtube' + index; - var youTubePlayerParams = "?wmode=opaque&autoplay=0&enablejsapi=1"; + var slideUrlParams = videoInfo.youtube[2] + ? videoInfo.youtube[2] + '&' + : ''; + var youTubePlayerParams = "?" + slideUrlParams + "wmode=opaque&autoplay=0&mute=1&enablejsapi=1"; var playerParams = youTubePlayerParams + (this.settings.youTubePlayerParams ? '&' + param(this.settings.youTubePlayerParams) diff --git a/dist/plugins/zoom/lg-zoom.es5.js b/dist/plugins/zoom/lg-zoom.es5.js index 718af2cb6..53c71364e 100644 --- a/dist/plugins/zoom/lg-zoom.es5.js +++ b/dist/plugins/zoom/lg-zoom.es5.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/zoom/lg-zoom.min.js b/dist/plugins/zoom/lg-zoom.min.js index fd7447f17..b37b83ad1 100644 --- a/dist/plugins/zoom/lg-zoom.min.js +++ b/dist/plugins/zoom/lg-zoom.min.js @@ -1,5 +1,5 @@ /** - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/dist/plugins/zoom/lg-zoom.umd.js b/dist/plugins/zoom/lg-zoom.umd.js index 1676185d9..33f4eb810 100644 --- a/dist/plugins/zoom/lg-zoom.umd.js +++ b/dist/plugins/zoom/lg-zoom.umd.js @@ -1,5 +1,5 @@ /*! - * lightgallery | 2.2.0 | August 20th 2021 + * lightgallery | 2.3.0-beta | August 29th 2021 * http://www.lightgalleryjs.com/ * Copyright (c) 2020 Sachin Neravath; * @license GPLv3 diff --git a/package.json b/package.json index 953b9df5d..3c94e6018 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lightgallery", - "version": "2.2.0", + "version": "2.3.0-beta", "description": "lightGallery is a feature-rich, modular JavaScript gallery plugin for building beautiful image and video galleries for the web and the mobile", "keywords": [ "JavaScript",