prokat/api/jquery/plugins/lightGallery/2.7.2/lg-relative-caption.umd.min.js
2025-06-16 18:28:08 +05:00

1 line
2.0 KiB
JavaScript
Executable File

!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="lgContainerResize",o="lgSlideItemLoad",n="lgBeforeSlide",s="lgAfterSlide",i={relativeCaption:!1};function l(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 l.prototype.init=function(){var i=this;this.settings.relativeCaption&&(this.core.LGel.on(o+".caption",function(t){var t=t.detail,e=t.index,t=t.delay;setTimeout(function(){e===i.core.index&&i.setRelativeCaption(e)},t)}),this.core.LGel.on(s+".caption",function(t){var e=t.detail.index;setTimeout(function(){i.core.getSlideItem(e).hasClass("lg-complete")&&i.setRelativeCaption(e)})}),this.core.LGel.on(n+".caption",function(t){var e=t.detail.index;setTimeout(function(){i.core.getSlideItem(e).removeClass("lg-show-caption")})}),this.core.LGel.on(t+".caption",function(t){i.setRelativeCaption(i.core.index)}))},l.prototype.setCaptionStyle=function(t,e,i){var o=this.core.getSlideItem(t).find(".lg-relative-caption-item"),t=this.core.getSlideItem(t).find(".lg-sub-html"),o=(t.css("width",e.width+"px").css("left",e.left+"px"),o.get().getBoundingClientRect()),i=i.bottom-e.bottom-o.height;t.css("top","auto").css("bottom",Math.max(i,0)+"px")},l.prototype.setRelativeCaption=function(t){var e,i,o=this.core.getSlideItem(t);o.hasClass("lg-current")&&(e=this.core.getSlideItem(t).find(".lg-object").get().getBoundingClientRect(),i=this.core.getSlideItem(t).get().getBoundingClientRect(),this.setCaptionStyle(t,e,i),o.addClass("lg-show-caption"))},l.prototype.destroy=function(){this.core.LGel.off(".caption")},l});