UNPKG

5.48 kBJavaScriptView Raw
1/*!
2 * lightgallery | 2.2.1 | September 4th 2021
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 };
70
71 var mediumZoomSettings = {
72 margin: 40,
73 mediumZoom: true,
74 backgroundColor: '#000',
75 };
76
77 var MediumZoom = /** @class */ (function () {
78 function MediumZoom(instance, $LG) {
79 var _this = this;
80 // get lightGallery core plugin instance
81 this.core = instance;
82 this.$LG = $LG;
83 // Set margin
84 this.core.getMediaContainerPosition = function () {
85 return {
86 top: _this.settings.margin,
87 bottom: _this.settings.margin,
88 };
89 };
90 // Override some of lightGallery default settings
91 var defaultSettings = {
92 controls: false,
93 download: false,
94 counter: false,
95 showCloseIcon: false,
96 extraProps: ['lgBackgroundColor'],
97 closeOnTap: false,
98 enableSwipe: false,
99 enableDrag: false,
100 swipeToClose: false,
101 addClass: this.core.settings.addClass + ' lg-medium-zoom',
102 };
103 this.core.settings = __assign(__assign({}, this.core.settings), defaultSettings);
104 // extend module default settings with lightGallery core settings
105 this.settings = __assign(__assign(__assign({}, mediumZoomSettings), this.core.settings), defaultSettings);
106 return this;
107 }
108 MediumZoom.prototype.toggleItemClass = function () {
109 for (var index = 0; index < this.core.items.length; index++) {
110 var $element = this.$LG(this.core.items[index]);
111 $element.toggleClass('lg-medium-zoom-item');
112 }
113 };
114 MediumZoom.prototype.init = function () {
115 var _this = this;
116 if (!this.settings.mediumZoom) {
117 return;
118 }
119 this.core.LGel.on(lGEvents.beforeOpen + ".medium", function () {
120 _this.core.$backdrop.css('background-color', _this.core.galleryItems[_this.core.index].lgBackgroundColor ||
121 _this.settings.backgroundColor);
122 });
123 this.toggleItemClass();
124 this.core.outer.on('click.lg.medium', function () {
125 _this.core.closeGallery();
126 });
127 };
128 MediumZoom.prototype.destroy = function () {
129 this.toggleItemClass();
130 };
131 return MediumZoom;
132 }());
133
134 return MediumZoom;
135
136})));
137//# sourceMappingURL=lg-medium-zoom.umd.js.map