UNPKG

lightgallery

Version:

lightGallery is a feature-rich, modular JavaScript gallery plugin for building beautiful image and video galleries for the web and the mobile

9 lines (7 loc) 2.01 kB
/** * lightgallery | 2.1.7 | July 1st 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).lgRelativeCaption=e()}(this,function(){"use strict";var e=function(){return(e=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)},t="lgSlideItemLoad",o="lgBeforeSlide",n="lgAfterSlide",i={relativeCaption:!1};function s(t){this.core=t;t={addClass:this.core.settings.addClass+" lg-relative-caption"};return this.core.settings=e(e({},this.core.settings),t),this.settings=e(e(e({},i),this.core.settings),t),this}return s.prototype.init=function(){var i=this;this.settings.relativeCaption&&(this.core.LGel.on(t+".caption",function(t){var t=t.detail,e=t.index,t=t.delay;setTimeout(function(){i.setRelativeCaption(e)},t)}),this.core.LGel.on(n+".caption",function(t){var e=t.detail.index;setTimeout(function(){i.core.getSlideItem(e).hasClass("lg-complete")&&i.setRelativeCaption(e)})}),this.core.LGel.on(o+".caption",function(t){var e=t.detail.index;setTimeout(function(){i.core.getSlideItem(e).removeClass("lg-show-caption")})}))},s.prototype.setCaptionStyle=function(t,e){var i=this.core.getSlideItem(t).find(".lg-relative-caption-item"),o=this.core.getSlideItem(t).find(".lg-sub-html"),t=i.get().getBoundingClientRect(),i=e.bottom;e.height+t.height>=e.bottom&&(i-=t.height),o.css("width",e.width+"px").css("left",e.left+"px").css("top",i+"px")},s.prototype.setRelativeCaption=function(t){var e,i=this.core.getSlideItem(t);i.hasClass("lg-current")&&(e=this.core.getSlideItem(t).find(".lg-object").get().getBoundingClientRect(),this.setCaptionStyle(t,e),i.addClass("lg-show-caption"))},s.prototype.destroy=function(){this.core.LGel.off(".caption")},s});