UNPKG

5.6 kBJavaScriptView Raw
1/*!
2 * lightgallery | 2.5.0 | June 13th 2022
3 * http://www.lightgalleryjs.com/
4 * Copyright (c) 2020 Sachin Neravath;
5 * @license GPLv3
6 */
7
8(function (global, factory) {
9 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
10 typeof define === 'function' && define.amd ? define(factory) :
11 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.lgMediumZoom = factory());
12}(this, (function () { 'use strict';
13
14 /*! *****************************************************************************
15 Copyright (c) Microsoft Corporation.
16
17 Permission to use, copy, modify, and/or distribute this software for any
18 purpose with or without fee is hereby granted.
19
20 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
21 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
22 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
23 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
24 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
25 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
26 PERFORMANCE OF THIS SOFTWARE.
27 ***************************************************************************** */
28
29 var __assign = function() {
30 __assign = Object.assign || function __assign(t) {
31 for (var s, i = 1, n = arguments.length; i < n; i++) {
32 s = arguments[i];
33 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
34 }
35 return t;
36 };
37 return __assign.apply(this, arguments);
38 };
39
40 /**
41 * List of lightGallery events
42 * All events should be documented here
43 * Below interfaces are used to build the website documentations
44 * */
45 var lGEvents = {
46 afterAppendSlide: 'lgAfterAppendSlide',
47 init: 'lgInit',
48 hasVideo: 'lgHasVideo',
49 containerResize: 'lgContainerResize',
50 updateSlides: 'lgUpdateSlides',
51 afterAppendSubHtml: 'lgAfterAppendSubHtml',
52 beforeOpen: 'lgBeforeOpen',
53 afterOpen: 'lgAfterOpen',
54 slideItemLoad: 'lgSlideItemLoad',
55 beforeSlide: 'lgBeforeSlide',
56 afterSlide: 'lgAfterSlide',
57 posterClick: 'lgPosterClick',
58 dragStart: 'lgDragStart',
59 dragMove: 'lgDragMove',
60 dragEnd: 'lgDragEnd',
61 beforeNextSlide: 'lgBeforeNextSlide',
62 beforePrevSlide: 'lgBeforePrevSlide',
63 beforeClose: 'lgBeforeClose',
64 afterClose: 'lgAfterClose',
65 rotateLeft: 'lgRotateLeft',
66 rotateRight: 'lgRotateRight',
67 flipHorizontal: 'lgFlipHorizontal',
68 flipVertical: 'lgFlipVertical',
69 autoplay: 'lgAutoplay',
70 autoplayStart: 'lgAutoplayStart',
71 autoplayStop: 'lgAutoplayStop',
72 };
73
74 var mediumZoomSettings = {
75 margin: 40,
76 mediumZoom: true,
77 backgroundColor: '#000',
78 };
79
80 var MediumZoom = /** @class */ (function () {
81 function MediumZoom(instance, $LG) {
82 var _this = this;
83 // get lightGallery core plugin instance
84 this.core = instance;
85 this.$LG = $LG;
86 // Set margin
87 this.core.getMediaContainerPosition = function () {
88 return {
89 top: _this.settings.margin,
90 bottom: _this.settings.margin,
91 };
92 };
93 // Override some of lightGallery default settings
94 var defaultSettings = {
95 controls: false,
96 download: false,
97 counter: false,
98 showCloseIcon: false,
99 extraProps: ['lgBackgroundColor'],
100 closeOnTap: false,
101 enableSwipe: false,
102 enableDrag: false,
103 swipeToClose: false,
104 addClass: this.core.settings.addClass + ' lg-medium-zoom',
105 };
106 this.core.settings = __assign(__assign({}, this.core.settings), defaultSettings);
107 // extend module default settings with lightGallery core settings
108 this.settings = __assign(__assign(__assign({}, mediumZoomSettings), this.core.settings), defaultSettings);
109 return this;
110 }
111 MediumZoom.prototype.toggleItemClass = function () {
112 for (var index = 0; index < this.core.items.length; index++) {
113 var $element = this.$LG(this.core.items[index]);
114 $element.toggleClass('lg-medium-zoom-item');
115 }
116 };
117 MediumZoom.prototype.init = function () {
118 var _this = this;
119 if (!this.settings.mediumZoom) {
120 return;
121 }
122 this.core.LGel.on(lGEvents.beforeOpen + ".medium", function () {
123 _this.core.$backdrop.css('background-color', _this.core.galleryItems[_this.core.index].lgBackgroundColor ||
124 _this.settings.backgroundColor);
125 });
126 this.toggleItemClass();
127 this.core.outer.on('click.lg.medium', function () {
128 _this.core.closeGallery();
129 });
130 };
131 MediumZoom.prototype.destroy = function () {
132 this.toggleItemClass();
133 };
134 return MediumZoom;
135 }());
136
137 return MediumZoom;
138
139})));
140//# sourceMappingURL=lg-medium-zoom.umd.js.map