lightgallery
Version:
lightGallery is a feature-rich, modular JavaScript gallery plugin for building beautiful image and video galleries for the web and the mobile
2 lines (1 loc) • 1.67 kB
JavaScript
!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).lgMediumZoom=o()}(this,function(){"use strict";const e="lgBeforeOpen",o={margin:40,mediumZoom:!0,backgroundColor:"#000"};var t=Object.defineProperty,s=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,n=(e,o,s)=>o in e?t(e,o,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[o]=s,l=(e,o)=>{for(var t in o||(o={}))i.call(o,t)&&n(e,t,o[t]);if(s)for(var t of s(o))r.call(o,t)&&n(e,t,o[t]);return e};return class{constructor(e,t){this.core=e,this.$LG=t,this.core.getMediaContainerPosition=()=>({top:this.settings.margin,bottom:this.settings.margin});const s={controls:!1,download:!1,counter:!1,showCloseIcon:!1,extraProps:["lgBackgroundColor"],closeOnTap:!1,enableSwipe:!1,enableDrag:!1,swipeToClose:!1,addClass:this.core.settings.addClass+" lg-medium-zoom"};return this.core.settings=l(l({},this.core.settings),s),this.settings=l(l(l({},o),this.core.settings),s),this}toggleItemClass(){for(let e=0;e<this.core.items.length;e++){this.$LG(this.core.items[e]).toggleClass("lg-medium-zoom-item")}}init(){this.settings.mediumZoom&&(this.core.LGel.on(`${e}.medium`,()=>{this.core.$backdrop.css("background-color",this.core.galleryItems[this.core.index].lgBackgroundColor||this.settings.backgroundColor)}),this.toggleItemClass(),this.core.outer.on("click.lg.medium",e=>{e.composedPath().some(e=>{var o;return!!(null==(o=e.classList)?void 0:o.contains("lg-toolbar"))})||this.core.closeGallery()}))}destroy(){this.toggleItemClass()}}});