UNPKG

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