PluginProbe
Photonic Gallery & Lightbox for Flickr, SmugMug & Others / 3.37
Photonic Gallery & Lightbox for Flickr, SmugMug & Others v3.37
3.37 3.36 3.35 3.34 3.33 2.19 2.20 2.21 2.22 2.23 2.24 2.25 2.26 2.27 2.28 2.29 2.30 2.31 2.32 2.33 2.34 2.40 2.41 2.42 2.43 All 142 releases
photonic / include / ext / lightgallery / lightgallery-plugins.js

lightgallery-plugins.js in Photonic Gallery & Lightbox for Flickr, SmugMug & Others 3.37, at include/ext/lightgallery/lightgallery-plugins.js

1,865 lines 60.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*!
2 * lightgallery | 2.7.1 | January 11th 2023
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.lgAutoplay = 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 autoplaySettings = {
75 autoplay: true,
76 slideShowAutoplay: false,
77 slideShowInterval: 5000,
78 progressBar: true,
79 forceSlideShowAutoplay: false,
80 autoplayControls: true,
81 appendAutoplayControlsTo: '.lg-toolbar',
82 autoplayPluginStrings: {
83 toggleAutoplay: 'Toggle Autoplay',
84 },
85 };
86
87 /**
88 * Creates the autoplay plugin.
89 * @param {object} element - lightGallery element
90 */
91 var Autoplay = /** @class */ (function () {
92 function Autoplay(instance) {
93 this.core = instance;
94 // extend module default settings with lightGallery core settings
95 this.settings = __assign(__assign({}, autoplaySettings), this.core.settings);
96 return this;
97 }
98 Autoplay.prototype.init = function () {
99 var _this = this;
100 if (!this.settings.autoplay) {
101 return;
102 }
103 this.interval = false;
104 // Identify if slide happened from autoplay
105 this.fromAuto = true;
106 // Identify if autoplay canceled from touch/drag
107 this.pausedOnTouchDrag = false;
108 this.pausedOnSlideChange = false;
109 // append autoplay controls
110 if (this.settings.autoplayControls) {
111 this.controls();
112 }
113 // Create progress bar
114 if (this.settings.progressBar) {
115 this.core.outer.append('<div class="lg-progress-bar"><div class="lg-progress"></div></div>');
116 }
117 // Start autoplay
118 if (this.settings.slideShowAutoplay) {
119 this.core.LGel.once(lGEvents.slideItemLoad + ".autoplay", function () {
120 _this.startAutoPlay();
121 });
122 }
123 // cancel interval on touchstart and dragstart
124 this.core.LGel.on(lGEvents.dragStart + ".autoplay touchstart.lg.autoplay", function () {
125 if (_this.interval) {
126 _this.stopAutoPlay();
127 _this.pausedOnTouchDrag = true;
128 }
129 });
130 // restore autoplay if autoplay canceled from touchstart / dragstart
131 this.core.LGel.on(lGEvents.dragEnd + ".autoplay touchend.lg.autoplay", function () {
132 if (!_this.interval && _this.pausedOnTouchDrag) {
133 _this.startAutoPlay();
134 _this.pausedOnTouchDrag = false;
135 }
136 });
137 this.core.LGel.on(lGEvents.beforeSlide + ".autoplay", function () {
138 _this.showProgressBar();
139 if (!_this.fromAuto && _this.interval) {
140 _this.stopAutoPlay();
141 _this.pausedOnSlideChange = true;
142 }
143 else {
144 _this.pausedOnSlideChange = false;
145 }
146 _this.fromAuto = false;
147 });
148 // restore autoplay if autoplay canceled from touchstart / dragstart
149 this.core.LGel.on(lGEvents.afterSlide + ".autoplay", function () {
150 if (_this.pausedOnSlideChange &&
151 !_this.interval &&
152 _this.settings.forceSlideShowAutoplay) {
153 _this.startAutoPlay();
154 _this.pausedOnSlideChange = false;
155 }
156 });
157 // set progress
158 this.showProgressBar();
159 };
160 Autoplay.prototype.showProgressBar = function () {
161 var _this = this;
162 if (this.settings.progressBar && this.fromAuto) {
163 var _$progressBar_1 = this.core.outer.find('.lg-progress-bar');
164 var _$progress_1 = this.core.outer.find('.lg-progress');
165 if (this.interval) {
166 _$progress_1.removeAttr('style');
167 _$progressBar_1.removeClass('lg-start');
168 setTimeout(function () {
169 _$progress_1.css('transition', 'width ' +
170 (_this.core.settings.speed +
171 _this.settings.slideShowInterval) +
172 'ms ease 0s');
173 _$progressBar_1.addClass('lg-start');
174 }, 20);
175 }
176 }
177 };
178 // Manage autoplay via play/stop buttons
179 Autoplay.prototype.controls = function () {
180 var _this = this;
181 var _html = "<button aria-label=\"" + this.settings.autoplayPluginStrings['toggleAutoplay'] + "\" type=\"button\" class=\"lg-autoplay-button lg-icon\"></button>";
182 // Append autoplay controls
183 this.core.outer
184 .find(this.settings.appendAutoplayControlsTo)
185 .append(_html);
186 this.core.outer
187 .find('.lg-autoplay-button')
188 .first()
189 .on('click.lg.autoplay', function () {
190 if (_this.core.outer.hasClass('lg-show-autoplay')) {
191 _this.stopAutoPlay();
192 }
193 else {
194 if (!_this.interval) {
195 _this.startAutoPlay();
196 }
197 }
198 });
199 };
200 // Autostart gallery
201 Autoplay.prototype.startAutoPlay = function () {
202 var _this = this;
203 this.core.outer
204 .find('.lg-progress')
205 .css('transition', 'width ' +
206 (this.core.settings.speed +
207 this.settings.slideShowInterval) +
208 'ms ease 0s');
209 this.core.outer.addClass('lg-show-autoplay');
210 this.core.outer.find('.lg-progress-bar').addClass('lg-start');
211 this.core.LGel.trigger(lGEvents.autoplayStart, {
212 index: this.core.index,
213 });
214 this.interval = setInterval(function () {
215 if (_this.core.index + 1 < _this.core.galleryItems.length) {
216 _this.core.index++;
217 }
218 else {
219 _this.core.index = 0;
220 }
221 _this.core.LGel.trigger(lGEvents.autoplay, {
222 index: _this.core.index,
223 });
224 _this.fromAuto = true;
225 _this.core.slide(_this.core.index, false, false, 'next');
226 }, this.core.settings.speed + this.settings.slideShowInterval);
227 };
228 // cancel Autostart
229 Autoplay.prototype.stopAutoPlay = function () {
230 if (this.interval) {
231 this.core.LGel.trigger(lGEvents.autoplayStop, {
232 index: this.core.index,
233 });
234 this.core.outer.find('.lg-progress').removeAttr('style');
235 this.core.outer.removeClass('lg-show-autoplay');
236 this.core.outer.find('.lg-progress-bar').removeClass('lg-start');
237 }
238 clearInterval(this.interval);
239 this.interval = false;
240 };
241 Autoplay.prototype.closeGallery = function () {
242 this.stopAutoPlay();
243 };
244 Autoplay.prototype.destroy = function () {
245 if (this.settings.autoplay) {
246 this.core.outer.find('.lg-progress-bar').remove();
247 }
248 // Remove all event listeners added by autoplay plugin
249 this.core.LGel.off('.lg.autoplay');
250 this.core.LGel.off('.autoplay');
251 };
252 return Autoplay;
253 }());
254
255 return Autoplay;
256
257 })));
258
259 /*!
260 * lightgallery | 2.7.1 | January 11th 2023
261 * http://www.lightgalleryjs.com/
262 * Copyright (c) 2020 Sachin Neravath;
263 * @license GPLv3
264 */
265
266 (function (global, factory) {
267 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
268 typeof define === 'function' && define.amd ? define(factory) :
269 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.lgFullscreen = factory());
270 }(this, (function () { 'use strict';
271
272 /*! *****************************************************************************
273 Copyright (c) Microsoft Corporation.
274
275 Permission to use, copy, modify, and/or distribute this software for any
276 purpose with or without fee is hereby granted.
277
278 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
279 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
280 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
281 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
282 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
283 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
284 PERFORMANCE OF THIS SOFTWARE.
285 ***************************************************************************** */
286
287 var __assign = function() {
288 __assign = Object.assign || function __assign(t) {
289 for (var s, i = 1, n = arguments.length; i < n; i++) {
290 s = arguments[i];
291 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
292 }
293 return t;
294 };
295 return __assign.apply(this, arguments);
296 };
297
298 var fullscreenSettings = {
299 fullScreen: true,
300 fullscreenPluginStrings: {
301 toggleFullscreen: 'Toggle Fullscreen',
302 },
303 };
304
305 var FullScreen = /** @class */ (function () {
306 function FullScreen(instance, $LG) {
307 // get lightGallery core plugin instance
308 this.core = instance;
309 this.$LG = $LG;
310 // extend module default settings with lightGallery core settings
311 this.settings = __assign(__assign({}, fullscreenSettings), this.core.settings);
312 return this;
313 }
314 FullScreen.prototype.init = function () {
315 var fullScreen = '';
316 if (this.settings.fullScreen) {
317 // check for fullscreen browser support
318 if (!document.fullscreenEnabled &&
319 !document.webkitFullscreenEnabled &&
320 !document.mozFullScreenEnabled &&
321 !document.msFullscreenEnabled) {
322 return;
323 }
324 else {
325 fullScreen = "<button type=\"button\" aria-label=\"" + this.settings.fullscreenPluginStrings['toggleFullscreen'] + "\" class=\"lg-fullscreen lg-icon\"></button>";
326 this.core.$toolbar.append(fullScreen);
327 this.fullScreen();
328 }
329 }
330 };
331 FullScreen.prototype.isFullScreen = function () {
332 return (document.fullscreenElement ||
333 document.mozFullScreenElement ||
334 document.webkitFullscreenElement ||
335 document.msFullscreenElement);
336 };
337 FullScreen.prototype.requestFullscreen = function () {
338 var el = document.documentElement;
339 if (el.requestFullscreen) {
340 el.requestFullscreen();
341 }
342 else if (el.msRequestFullscreen) {
343 el.msRequestFullscreen();
344 }
345 else if (el.mozRequestFullScreen) {
346 el.mozRequestFullScreen();
347 }
348 else if (el.webkitRequestFullscreen) {
349 el.webkitRequestFullscreen();
350 }
351 };
352 FullScreen.prototype.exitFullscreen = function () {
353 if (document.exitFullscreen) {
354 document.exitFullscreen();
355 }
356 else if (document.msExitFullscreen) {
357 document.msExitFullscreen();
358 }
359 else if (document.mozCancelFullScreen) {
360 document.mozCancelFullScreen();
361 }
362 else if (document.webkitExitFullscreen) {
363 document.webkitExitFullscreen();
364 }
365 };
366 // https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Using_full_screen_mode
367 FullScreen.prototype.fullScreen = function () {
368 var _this = this;
369 this.$LG(document).on("fullscreenchange.lg.global" + this.core.lgId + " \n webkitfullscreenchange.lg.global" + this.core.lgId + " \n mozfullscreenchange.lg.global" + this.core.lgId + " \n MSFullscreenChange.lg.global" + this.core.lgId, function () {
370 if (!_this.core.lgOpened)
371 return;
372 _this.core.outer.toggleClass('lg-fullscreen-on');
373 });
374 this.core.outer
375 .find('.lg-fullscreen')
376 .first()
377 .on('click.lg', function () {
378 if (_this.isFullScreen()) {
379 _this.exitFullscreen();
380 }
381 else {
382 _this.requestFullscreen();
383 }
384 });
385 };
386 FullScreen.prototype.closeGallery = function () {
387 // exit from fullscreen if activated
388 if (this.isFullScreen()) {
389 this.exitFullscreen();
390 }
391 };
392 FullScreen.prototype.destroy = function () {
393 this.$LG(document).off("fullscreenchange.lg.global" + this.core.lgId + " \n webkitfullscreenchange.lg.global" + this.core.lgId + " \n mozfullscreenchange.lg.global" + this.core.lgId + " \n MSFullscreenChange.lg.global" + this.core.lgId);
394 };
395 return FullScreen;
396 }());
397
398 return FullScreen;
399
400 })));
401
402
403 /*!
404 * lightgallery | 2.7.1 | January 11th 2023
405 * http://www.lightgalleryjs.com/
406 * Copyright (c) 2020 Sachin Neravath;
407 * @license GPLv3
408 */
409
410 (function (global, factory) {
411 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
412 typeof define === 'function' && define.amd ? define(factory) :
413 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.lgThumbnail = factory());
414 }(this, (function () { 'use strict';
415
416 /*! *****************************************************************************
417 Copyright (c) Microsoft Corporation.
418
419 Permission to use, copy, modify, and/or distribute this software for any
420 purpose with or without fee is hereby granted.
421
422 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
423 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
424 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
425 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
426 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
427 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
428 PERFORMANCE OF THIS SOFTWARE.
429 ***************************************************************************** */
430
431 var __assign = function() {
432 __assign = Object.assign || function __assign(t) {
433 for (var s, i = 1, n = arguments.length; i < n; i++) {
434 s = arguments[i];
435 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
436 }
437 return t;
438 };
439 return __assign.apply(this, arguments);
440 };
441
442 var thumbnailsSettings = {
443 thumbnail: true,
444 animateThumb: true,
445 currentPagerPosition: 'middle',
446 alignThumbnails: 'middle',
447 thumbWidth: 100,
448 thumbHeight: '80px',
449 thumbMargin: 5,
450 appendThumbnailsTo: '.lg-components',
451 toggleThumb: false,
452 enableThumbDrag: true,
453 enableThumbSwipe: true,
454 thumbnailSwipeThreshold: 10,
455 loadYouTubeThumbnail: true,
456 youTubeThumbSize: 1,
457 thumbnailPluginStrings: {
458 toggleThumbnails: 'Toggle thumbnails',
459 },
460 };
461
462 /**
463 * List of lightGallery events
464 * All events should be documented here
465 * Below interfaces are used to build the website documentations
466 * */
467 var lGEvents = {
468 afterAppendSlide: 'lgAfterAppendSlide',
469 init: 'lgInit',
470 hasVideo: 'lgHasVideo',
471 containerResize: 'lgContainerResize',
472 updateSlides: 'lgUpdateSlides',
473 afterAppendSubHtml: 'lgAfterAppendSubHtml',
474 beforeOpen: 'lgBeforeOpen',
475 afterOpen: 'lgAfterOpen',
476 slideItemLoad: 'lgSlideItemLoad',
477 beforeSlide: 'lgBeforeSlide',
478 afterSlide: 'lgAfterSlide',
479 posterClick: 'lgPosterClick',
480 dragStart: 'lgDragStart',
481 dragMove: 'lgDragMove',
482 dragEnd: 'lgDragEnd',
483 beforeNextSlide: 'lgBeforeNextSlide',
484 beforePrevSlide: 'lgBeforePrevSlide',
485 beforeClose: 'lgBeforeClose',
486 afterClose: 'lgAfterClose',
487 rotateLeft: 'lgRotateLeft',
488 rotateRight: 'lgRotateRight',
489 flipHorizontal: 'lgFlipHorizontal',
490 flipVertical: 'lgFlipVertical',
491 autoplay: 'lgAutoplay',
492 autoplayStart: 'lgAutoplayStart',
493 autoplayStop: 'lgAutoplayStop',
494 };
495
496 var Thumbnail = /** @class */ (function () {
497 function Thumbnail(instance, $LG) {
498 this.thumbOuterWidth = 0;
499 this.thumbTotalWidth = 0;
500 this.translateX = 0;
501 this.thumbClickable = false;
502 // get lightGallery core plugin instance
503 this.core = instance;
504 this.$LG = $LG;
505 return this;
506 }
507 Thumbnail.prototype.init = function () {
508 // extend module default settings with lightGallery core settings
509 this.settings = __assign(__assign({}, thumbnailsSettings), this.core.settings);
510 this.thumbOuterWidth = 0;
511 this.thumbTotalWidth =
512 this.core.galleryItems.length *
513 (this.settings.thumbWidth + this.settings.thumbMargin);
514 // Thumbnail animation value
515 this.translateX = 0;
516 this.setAnimateThumbStyles();
517 if (!this.core.settings.allowMediaOverlap) {
518 this.settings.toggleThumb = false;
519 }
520 if (this.settings.thumbnail) {
521 this.build();
522 if (this.settings.animateThumb) {
523 if (this.settings.enableThumbDrag) {
524 this.enableThumbDrag();
525 }
526 if (this.settings.enableThumbSwipe) {
527 this.enableThumbSwipe();
528 }
529 this.thumbClickable = false;
530 }
531 else {
532 this.thumbClickable = true;
533 }
534 this.toggleThumbBar();
535 this.thumbKeyPress();
536 }
537 };
538 Thumbnail.prototype.build = function () {
539 var _this = this;
540 this.setThumbMarkup();
541 this.manageActiveClassOnSlideChange();
542 this.$lgThumb.first().on('click.lg touchend.lg', function (e) {
543 var $target = _this.$LG(e.target);
544 if (!$target.hasAttribute('data-lg-item-id')) {
545 return;
546 }
547 setTimeout(function () {
548 // In IE9 and bellow touch does not support
549 // Go to slide if browser does not support css transitions
550 if (_this.thumbClickable && !_this.core.lgBusy) {
551 var index = parseInt($target.attr('data-lg-item-id'));
552 _this.core.slide(index, false, true, false);
553 }
554 }, 50);
555 });
556 this.core.LGel.on(lGEvents.beforeSlide + ".thumb", function (event) {
557 var index = event.detail.index;
558 _this.animateThumb(index);
559 });
560 this.core.LGel.on(lGEvents.beforeOpen + ".thumb", function () {
561 _this.thumbOuterWidth = _this.core.outer.get().offsetWidth;
562 });
563 this.core.LGel.on(lGEvents.updateSlides + ".thumb", function () {
564 _this.rebuildThumbnails();
565 });
566 this.core.LGel.on(lGEvents.containerResize + ".thumb", function () {
567 if (!_this.core.lgOpened)
568 return;
569 setTimeout(function () {
570 _this.thumbOuterWidth = _this.core.outer.get().offsetWidth;
571 _this.animateThumb(_this.core.index);
572 _this.thumbOuterWidth = _this.core.outer.get().offsetWidth;
573 }, 50);
574 });
575 };
576 Thumbnail.prototype.setThumbMarkup = function () {
577 var thumbOuterClassNames = 'lg-thumb-outer ';
578 if (this.settings.alignThumbnails) {
579 thumbOuterClassNames += "lg-thumb-align-" + this.settings.alignThumbnails;
580 }
581 var html = "<div class=\"" + thumbOuterClassNames + "\">\n <div class=\"lg-thumb lg-group\">\n </div>\n </div>";
582 this.core.outer.addClass('lg-has-thumb');
583 if (this.settings.appendThumbnailsTo === '.lg-components') {
584 this.core.$lgComponents.append(html);
585 }
586 else {
587 this.core.outer.append(html);
588 }
589 this.$thumbOuter = this.core.outer.find('.lg-thumb-outer').first();
590 this.$lgThumb = this.core.outer.find('.lg-thumb').first();
591 if (this.settings.animateThumb) {
592 this.core.outer
593 .find('.lg-thumb')
594 .css('transition-duration', this.core.settings.speed + 'ms')
595 .css('width', this.thumbTotalWidth + 'px')
596 .css('position', 'relative');
597 }
598 this.setThumbItemHtml(this.core.galleryItems);
599 };
600 Thumbnail.prototype.enableThumbDrag = function () {
601 var _this = this;
602 var thumbDragUtils = {
603 cords: {
604 startX: 0,
605 endX: 0,
606 },
607 isMoved: false,
608 newTranslateX: 0,
609 startTime: new Date(),
610 endTime: new Date(),
611 touchMoveTime: 0,
612 };
613 var isDragging = false;
614 this.$thumbOuter.addClass('lg-grab');
615 this.core.outer
616 .find('.lg-thumb')
617 .first()
618 .on('mousedown.lg.thumb', function (e) {
619 if (_this.thumbTotalWidth > _this.thumbOuterWidth) {
620 // execute only on .lg-object
621 e.preventDefault();
622 thumbDragUtils.cords.startX = e.pageX;
623 thumbDragUtils.startTime = new Date();
624 _this.thumbClickable = false;
625 isDragging = true;
626 // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723
627 _this.core.outer.get().scrollLeft += 1;
628 _this.core.outer.get().scrollLeft -= 1;
629 // *
630 _this.$thumbOuter
631 .removeClass('lg-grab')
632 .addClass('lg-grabbing');
633 }
634 });
635 this.$LG(window).on("mousemove.lg.thumb.global" + this.core.lgId, function (e) {
636 if (!_this.core.lgOpened)
637 return;
638 if (isDragging) {
639 thumbDragUtils.cords.endX = e.pageX;
640 thumbDragUtils = _this.onThumbTouchMove(thumbDragUtils);
641 }
642 });
643 this.$LG(window).on("mouseup.lg.thumb.global" + this.core.lgId, function () {
644 if (!_this.core.lgOpened)
645 return;
646 if (thumbDragUtils.isMoved) {
647 thumbDragUtils = _this.onThumbTouchEnd(thumbDragUtils);
648 }
649 else {
650 _this.thumbClickable = true;
651 }
652 if (isDragging) {
653 isDragging = false;
654 _this.$thumbOuter.removeClass('lg-grabbing').addClass('lg-grab');
655 }
656 });
657 };
658 Thumbnail.prototype.enableThumbSwipe = function () {
659 var _this = this;
660 var thumbDragUtils = {
661 cords: {
662 startX: 0,
663 endX: 0,
664 },
665 isMoved: false,
666 newTranslateX: 0,
667 startTime: new Date(),
668 endTime: new Date(),
669 touchMoveTime: 0,
670 };
671 this.$lgThumb.on('touchstart.lg', function (e) {
672 if (_this.thumbTotalWidth > _this.thumbOuterWidth) {
673 e.preventDefault();
674 thumbDragUtils.cords.startX = e.targetTouches[0].pageX;
675 _this.thumbClickable = false;
676 thumbDragUtils.startTime = new Date();
677 }
678 });
679 this.$lgThumb.on('touchmove.lg', function (e) {
680 if (_this.thumbTotalWidth > _this.thumbOuterWidth) {
681 e.preventDefault();
682 thumbDragUtils.cords.endX = e.targetTouches[0].pageX;
683 thumbDragUtils = _this.onThumbTouchMove(thumbDragUtils);
684 }
685 });
686 this.$lgThumb.on('touchend.lg', function () {
687 if (thumbDragUtils.isMoved) {
688 thumbDragUtils = _this.onThumbTouchEnd(thumbDragUtils);
689 }
690 else {
691 _this.thumbClickable = true;
692 }
693 });
694 };
695 // Rebuild thumbnails
696 Thumbnail.prototype.rebuildThumbnails = function () {
697 var _this = this;
698 // Remove transitions
699 this.$thumbOuter.addClass('lg-rebuilding-thumbnails');
700 setTimeout(function () {
701 _this.thumbTotalWidth =
702 _this.core.galleryItems.length *
703 (_this.settings.thumbWidth + _this.settings.thumbMargin);
704 _this.$lgThumb.css('width', _this.thumbTotalWidth + 'px');
705 _this.$lgThumb.empty();
706 _this.setThumbItemHtml(_this.core.galleryItems);
707 _this.animateThumb(_this.core.index);
708 }, 50);
709 setTimeout(function () {
710 _this.$thumbOuter.removeClass('lg-rebuilding-thumbnails');
711 }, 200);
712 };
713 // @ts-check
714 Thumbnail.prototype.setTranslate = function (value) {
715 this.$lgThumb.css('transform', 'translate3d(-' + value + 'px, 0px, 0px)');
716 };
717 Thumbnail.prototype.getPossibleTransformX = function (left) {
718 if (left > this.thumbTotalWidth - this.thumbOuterWidth) {
719 left = this.thumbTotalWidth - this.thumbOuterWidth;
720 }
721 if (left < 0) {
722 left = 0;
723 }
724 return left;
725 };
726 Thumbnail.prototype.animateThumb = function (index) {
727 this.$lgThumb.css('transition-duration', this.core.settings.speed + 'ms');
728 if (this.settings.animateThumb) {
729 var position = 0;
730 switch (this.settings.currentPagerPosition) {
731 case 'left':
732 position = 0;
733 break;
734 case 'middle':
735 position =
736 this.thumbOuterWidth / 2 - this.settings.thumbWidth / 2;
737 break;
738 case 'right':
739 position = this.thumbOuterWidth - this.settings.thumbWidth;
740 }
741 this.translateX =
742 (this.settings.thumbWidth + this.settings.thumbMargin) * index -
743 1 -
744 position;
745 if (this.translateX > this.thumbTotalWidth - this.thumbOuterWidth) {
746 this.translateX = this.thumbTotalWidth - this.thumbOuterWidth;
747 }
748 if (this.translateX < 0) {
749 this.translateX = 0;
750 }
751 this.setTranslate(this.translateX);
752 }
753 };
754 Thumbnail.prototype.onThumbTouchMove = function (thumbDragUtils) {
755 thumbDragUtils.newTranslateX = this.translateX;
756 thumbDragUtils.isMoved = true;
757 thumbDragUtils.touchMoveTime = new Date().valueOf();
758 thumbDragUtils.newTranslateX -=
759 thumbDragUtils.cords.endX - thumbDragUtils.cords.startX;
760 thumbDragUtils.newTranslateX = this.getPossibleTransformX(thumbDragUtils.newTranslateX);
761 // move current slide
762 this.setTranslate(thumbDragUtils.newTranslateX);
763 this.$thumbOuter.addClass('lg-dragging');
764 return thumbDragUtils;
765 };
766 Thumbnail.prototype.onThumbTouchEnd = function (thumbDragUtils) {
767 thumbDragUtils.isMoved = false;
768 thumbDragUtils.endTime = new Date();
769 this.$thumbOuter.removeClass('lg-dragging');
770 var touchDuration = thumbDragUtils.endTime.valueOf() -
771 thumbDragUtils.startTime.valueOf();
772 var distanceXnew = thumbDragUtils.cords.endX - thumbDragUtils.cords.startX;
773 var speedX = Math.abs(distanceXnew) / touchDuration;
774 // Some magical numbers
775 // Can be improved
776 if (speedX > 0.15 &&
777 thumbDragUtils.endTime.valueOf() - thumbDragUtils.touchMoveTime < 30) {
778 speedX += 1;
779 if (speedX > 2) {
780 speedX += 1;
781 }
782 speedX =
783 speedX +
784 speedX * (Math.abs(distanceXnew) / this.thumbOuterWidth);
785 this.$lgThumb.css('transition-duration', Math.min(speedX - 1, 2) + 'settings');
786 distanceXnew = distanceXnew * speedX;
787 this.translateX = this.getPossibleTransformX(this.translateX - distanceXnew);
788 this.setTranslate(this.translateX);
789 }
790 else {
791 this.translateX = thumbDragUtils.newTranslateX;
792 }
793 if (Math.abs(thumbDragUtils.cords.endX - thumbDragUtils.cords.startX) <
794 this.settings.thumbnailSwipeThreshold) {
795 this.thumbClickable = true;
796 }
797 return thumbDragUtils;
798 };
799 Thumbnail.prototype.getThumbHtml = function (thumb, index) {
800 var slideVideoInfo = this.core.galleryItems[index].__slideVideoInfo || {};
801 var thumbImg;
802 if (slideVideoInfo.youtube) {
803 if (this.settings.loadYouTubeThumbnail) {
804 thumbImg =
805 '//img.youtube.com/vi/' +
806 slideVideoInfo.youtube[1] +
807 '/' +
808 this.settings.youTubeThumbSize +
809 '.jpg';
810 }
811 else {
812 thumbImg = thumb;
813 }
814 }
815 else {
816 thumbImg = thumb;
817 }
818 return "<div data-lg-item-id=\"" + index + "\" class=\"lg-thumb-item " + (index === this.core.index ? ' active' : '') + "\" \n style=\"width:" + this.settings.thumbWidth + "px; height: " + this.settings.thumbHeight + ";\n margin-right: " + this.settings.thumbMargin + "px;\">\n <img data-lg-item-id=\"" + index + "\" src=\"" + thumbImg + "\" />\n </div>";
819 };
820 Thumbnail.prototype.getThumbItemHtml = function (items) {
821 var thumbList = '';
822 for (var i = 0; i < items.length; i++) {
823 thumbList += this.getThumbHtml(items[i].thumb, i);
824 }
825 return thumbList;
826 };
827 Thumbnail.prototype.setThumbItemHtml = function (items) {
828 var thumbList = this.getThumbItemHtml(items);
829 this.$lgThumb.html(thumbList);
830 };
831 Thumbnail.prototype.setAnimateThumbStyles = function () {
832 if (this.settings.animateThumb) {
833 this.core.outer.addClass('lg-animate-thumb');
834 }
835 };
836 // Manage thumbnail active calss
837 Thumbnail.prototype.manageActiveClassOnSlideChange = function () {
838 var _this = this;
839 // manage active class for thumbnail
840 this.core.LGel.on(lGEvents.beforeSlide + ".thumb", function (event) {
841 var $thumb = _this.core.outer.find('.lg-thumb-item');
842 var index = event.detail.index;
843 $thumb.removeClass('active');
844 $thumb.eq(index).addClass('active');
845 });
846 };
847 // Toggle thumbnail bar
848 Thumbnail.prototype.toggleThumbBar = function () {
849 var _this = this;
850 if (this.settings.toggleThumb) {
851 this.core.outer.addClass('lg-can-toggle');
852 this.core.$toolbar.append('<button type="button" aria-label="' +
853 this.settings.thumbnailPluginStrings['toggleThumbnails'] +
854 '" class="lg-toggle-thumb lg-icon"></button>');
855 this.core.outer
856 .find('.lg-toggle-thumb')
857 .first()
858 .on('click.lg', function () {
859 _this.core.outer.toggleClass('lg-components-open');
860 });
861 }
862 };
863 Thumbnail.prototype.thumbKeyPress = function () {
864 var _this = this;
865 this.$LG(window).on("keydown.lg.thumb.global" + this.core.lgId, function (e) {
866 if (!_this.core.lgOpened || !_this.settings.toggleThumb)
867 return;
868 if (e.keyCode === 38) {
869 e.preventDefault();
870 _this.core.outer.addClass('lg-components-open');
871 }
872 else if (e.keyCode === 40) {
873 e.preventDefault();
874 _this.core.outer.removeClass('lg-components-open');
875 }
876 });
877 };
878 Thumbnail.prototype.destroy = function () {
879 if (this.settings.thumbnail) {
880 this.$LG(window).off(".lg.thumb.global" + this.core.lgId);
881 this.core.LGel.off('.lg.thumb');
882 this.core.LGel.off('.thumb');
883 this.$thumbOuter.remove();
884 this.core.outer.removeClass('lg-has-thumb');
885 }
886 };
887 return Thumbnail;
888 }());
889
890 return Thumbnail;
891
892 })));
893
894
895 /*!
896 * lightgallery | 2.7.1 | January 11th 2023
897 * http://www.lightgalleryjs.com/
898 * Copyright (c) 2020 Sachin Neravath;
899 * @license GPLv3
900 */
901
902 (function (global, factory) {
903 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
904 typeof define === 'function' && define.amd ? define(factory) :
905 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.lgZoom = factory());
906 }(this, (function () { 'use strict';
907
908 /*! *****************************************************************************
909 Copyright (c) Microsoft Corporation.
910
911 Permission to use, copy, modify, and/or distribute this software for any
912 purpose with or without fee is hereby granted.
913
914 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
915 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
916 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
917 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
918 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
919 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
920 PERFORMANCE OF THIS SOFTWARE.
921 ***************************************************************************** */
922
923 var __assign = function() {
924 __assign = Object.assign || function __assign(t) {
925 for (var s, i = 1, n = arguments.length; i < n; i++) {
926 s = arguments[i];
927 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
928 }
929 return t;
930 };
931 return __assign.apply(this, arguments);
932 };
933
934 var zoomSettings = {
935 scale: 1,
936 zoom: true,
937 actualSize: true,
938 showZoomInOutIcons: false,
939 actualSizeIcons: {
940 zoomIn: 'lg-zoom-in',
941 zoomOut: 'lg-zoom-out',
942 },
943 enableZoomAfter: 300,
944 zoomPluginStrings: {
945 zoomIn: 'Zoom in',
946 zoomOut: 'Zoom out',
947 viewActualSize: 'View actual size',
948 },
949 };
950
951 /**
952 * List of lightGallery events
953 * All events should be documented here
954 * Below interfaces are used to build the website documentations
955 * */
956 var lGEvents = {
957 afterAppendSlide: 'lgAfterAppendSlide',
958 init: 'lgInit',
959 hasVideo: 'lgHasVideo',
960 containerResize: 'lgContainerResize',
961 updateSlides: 'lgUpdateSlides',
962 afterAppendSubHtml: 'lgAfterAppendSubHtml',
963 beforeOpen: 'lgBeforeOpen',
964 afterOpen: 'lgAfterOpen',
965 slideItemLoad: 'lgSlideItemLoad',
966 beforeSlide: 'lgBeforeSlide',
967 afterSlide: 'lgAfterSlide',
968 posterClick: 'lgPosterClick',
969 dragStart: 'lgDragStart',
970 dragMove: 'lgDragMove',
971 dragEnd: 'lgDragEnd',
972 beforeNextSlide: 'lgBeforeNextSlide',
973 beforePrevSlide: 'lgBeforePrevSlide',
974 beforeClose: 'lgBeforeClose',
975 afterClose: 'lgAfterClose',
976 rotateLeft: 'lgRotateLeft',
977 rotateRight: 'lgRotateRight',
978 flipHorizontal: 'lgFlipHorizontal',
979 flipVertical: 'lgFlipVertical',
980 autoplay: 'lgAutoplay',
981 autoplayStart: 'lgAutoplayStart',
982 autoplayStop: 'lgAutoplayStop',
983 };
984
985 var ZOOM_TRANSITION_DURATION = 500;
986 var Zoom = /** @class */ (function () {
987 function Zoom(instance, $LG) {
988 // get lightGallery core plugin instance
989 this.core = instance;
990 this.$LG = $LG;
991 this.settings = __assign(__assign({}, zoomSettings), this.core.settings);
992 return this;
993 }
994 // Append Zoom controls. Actual size, Zoom-in, Zoom-out
995 Zoom.prototype.buildTemplates = function () {
996 var zoomIcons = this.settings.showZoomInOutIcons
997 ? "<button id=\"" + this.core.getIdName('lg-zoom-in') + "\" type=\"button\" aria-label=\"" + this.settings.zoomPluginStrings['zoomIn'] + "\" class=\"lg-zoom-in lg-icon\"></button><button id=\"" + this.core.getIdName('lg-zoom-out') + "\" type=\"button\" aria-label=\"" + this.settings.zoomPluginStrings['zoomIn'] + "\" class=\"lg-zoom-out lg-icon\"></button>"
998 : '';
999 if (this.settings.actualSize) {
1000 zoomIcons += "<button id=\"" + this.core.getIdName('lg-actual-size') + "\" type=\"button\" aria-label=\"" + this.settings.zoomPluginStrings['viewActualSize'] + "\" class=\"" + this.settings.actualSizeIcons.zoomIn + " lg-icon\"></button>";
1001 }
1002 this.core.outer.addClass('lg-use-transition-for-zoom');
1003 this.core.$toolbar.first().append(zoomIcons);
1004 };
1005 /**
1006 * @desc Enable zoom option only once the image is completely loaded
1007 * If zoomFromOrigin is true, Zoom is enabled once the dummy image has been inserted
1008 *
1009 * Zoom styles are defined under lg-zoomable CSS class.
1010 */
1011 Zoom.prototype.enableZoom = function (event) {
1012 var _this = this;
1013 // delay will be 0 except first time
1014 var _speed = this.settings.enableZoomAfter + event.detail.delay;
1015 // set _speed value 0 if gallery opened from direct url and if it is first slide
1016 if (this.$LG('body').first().hasClass('lg-from-hash') &&
1017 event.detail.delay) {
1018 // will execute only once
1019 _speed = 0;
1020 }
1021 else {
1022 // Remove lg-from-hash to enable starting animation.
1023 this.$LG('body').first().removeClass('lg-from-hash');
1024 }
1025 this.zoomableTimeout = setTimeout(function () {
1026 if (!_this.isImageSlide(_this.core.index)) {
1027 return;
1028 }
1029 _this.core.getSlideItem(event.detail.index).addClass('lg-zoomable');
1030 if (event.detail.index === _this.core.index) {
1031 _this.setZoomEssentials();
1032 }
1033 }, _speed + 30);
1034 };
1035 Zoom.prototype.enableZoomOnSlideItemLoad = function () {
1036 // Add zoomable class
1037 this.core.LGel.on(lGEvents.slideItemLoad + ".zoom", this.enableZoom.bind(this));
1038 };
1039 Zoom.prototype.getDragCords = function (e) {
1040 return {
1041 x: e.pageX,
1042 y: e.pageY,
1043 };
1044 };
1045 Zoom.prototype.getSwipeCords = function (e) {
1046 var x = e.touches[0].pageX;
1047 var y = e.touches[0].pageY;
1048 return {
1049 x: x,
1050 y: y,
1051 };
1052 };
1053 Zoom.prototype.getDragAllowedAxises = function (scale, scaleDiff) {
1054 var $image = this.core
1055 .getSlideItem(this.core.index)
1056 .find('.lg-image')
1057 .first()
1058 .get();
1059 var height = 0;
1060 var width = 0;
1061 var rect = $image.getBoundingClientRect();
1062 if (scale) {
1063 height = $image.offsetHeight * scale;
1064 width = $image.offsetWidth * scale;
1065 }
1066 else if (scaleDiff) {
1067 height = rect.height + scaleDiff * rect.height;
1068 width = rect.width + scaleDiff * rect.width;
1069 }
1070 else {
1071 height = rect.height;
1072 width = rect.width;
1073 }
1074 var allowY = height > this.containerRect.height;
1075 var allowX = width > this.containerRect.width;
1076 return {
1077 allowX: allowX,
1078 allowY: allowY,
1079 };
1080 };
1081 Zoom.prototype.setZoomEssentials = function () {
1082 this.containerRect = this.core.$content.get().getBoundingClientRect();
1083 };
1084 /**
1085 * @desc Image zoom
1086 * Translate the wrap and scale the image to get better user experience
1087 *
1088 * @param {String} scale - Zoom decrement/increment value
1089 */
1090 Zoom.prototype.zoomImage = function (scale, scaleDiff, reposition, resetToMax) {
1091 if (Math.abs(scaleDiff) <= 0)
1092 return;
1093 var offsetX = this.containerRect.width / 2 + this.containerRect.left;
1094 var offsetY = this.containerRect.height / 2 +
1095 this.containerRect.top +
1096 this.scrollTop;
1097 var originalX;
1098 var originalY;
1099 if (scale === 1) {
1100 this.positionChanged = false;
1101 }
1102 var dragAllowedAxises = this.getDragAllowedAxises(0, scaleDiff);
1103 var allowY = dragAllowedAxises.allowY, allowX = dragAllowedAxises.allowX;
1104 if (this.positionChanged) {
1105 originalX = this.left / (this.scale - scaleDiff);
1106 originalY = this.top / (this.scale - scaleDiff);
1107 this.pageX = offsetX - originalX;
1108 this.pageY = offsetY - originalY;
1109 this.positionChanged = false;
1110 }
1111 var possibleSwipeCords = this.getPossibleSwipeDragCords(scaleDiff);
1112 var x;
1113 var y;
1114 var _x = offsetX - this.pageX;
1115 var _y = offsetY - this.pageY;
1116 if (scale - scaleDiff > 1) {
1117 var scaleVal = (scale - scaleDiff) / Math.abs(scaleDiff);
1118 _x =
1119 (scaleDiff < 0 ? -_x : _x) +
1120 this.left * (scaleVal + (scaleDiff < 0 ? -1 : 1));
1121 _y =
1122 (scaleDiff < 0 ? -_y : _y) +
1123 this.top * (scaleVal + (scaleDiff < 0 ? -1 : 1));
1124 x = _x / scaleVal;
1125 y = _y / scaleVal;
1126 }
1127 else {
1128 var scaleVal = (scale - scaleDiff) * scaleDiff;
1129 x = _x * scaleVal;
1130 y = _y * scaleVal;
1131 }
1132 if (reposition) {
1133 if (allowX) {
1134 if (this.isBeyondPossibleLeft(x, possibleSwipeCords.minX)) {
1135 x = possibleSwipeCords.minX;
1136 }
1137 else if (this.isBeyondPossibleRight(x, possibleSwipeCords.maxX)) {
1138 x = possibleSwipeCords.maxX;
1139 }
1140 }
1141 else {
1142 if (scale > 1) {
1143 if (x < possibleSwipeCords.minX) {
1144 x = possibleSwipeCords.minX;
1145 }
1146 else if (x > possibleSwipeCords.maxX) {
1147 x = possibleSwipeCords.maxX;
1148 }
1149 }
1150 }
1151 // @todo fix this
1152 if (allowY) {
1153 if (this.isBeyondPossibleTop(y, possibleSwipeCords.minY)) {
1154 y = possibleSwipeCords.minY;
1155 }
1156 else if (this.isBeyondPossibleBottom(y, possibleSwipeCords.maxY)) {
1157 y = possibleSwipeCords.maxY;
1158 }
1159 }
1160 else {
1161 // If the translate value based on index of beyond the viewport, utilize the available space to prevent image being cut out
1162 if (scale > 1) {
1163 //If image goes beyond viewport top, use the minim possible translate value
1164 if (y < possibleSwipeCords.minY) {
1165 y = possibleSwipeCords.minY;
1166 }
1167 else if (y > possibleSwipeCords.maxY) {
1168 y = possibleSwipeCords.maxY;
1169 }
1170 }
1171 }
1172 }
1173 this.setZoomStyles({
1174 x: x,
1175 y: y,
1176 scale: scale,
1177 });
1178 this.left = x;
1179 this.top = y;
1180 if (resetToMax) {
1181 this.setZoomImageSize();
1182 }
1183 };
1184 Zoom.prototype.resetImageTranslate = function (index) {
1185 if (!this.isImageSlide(index)) {
1186 return;
1187 }
1188 var $image = this.core.getSlideItem(index).find('.lg-image').first();
1189 this.imageReset = false;
1190 $image.removeClass('reset-transition reset-transition-y reset-transition-x');
1191 this.core.outer.removeClass('lg-actual-size');
1192 $image.css('width', 'auto').css('height', 'auto');
1193 setTimeout(function () {
1194 $image.removeClass('no-transition');
1195 }, 10);
1196 };
1197 Zoom.prototype.setZoomImageSize = function () {
1198 var _this = this;
1199 var $image = this.core
1200 .getSlideItem(this.core.index)
1201 .find('.lg-image')
1202 .first();
1203 setTimeout(function () {
1204 var actualSizeScale = _this.getCurrentImageActualSizeScale();
1205 if (_this.scale >= actualSizeScale) {
1206 $image.addClass('no-transition');
1207 _this.imageReset = true;
1208 }
1209 }, ZOOM_TRANSITION_DURATION);
1210 setTimeout(function () {
1211 var actualSizeScale = _this.getCurrentImageActualSizeScale();
1212 if (_this.scale >= actualSizeScale) {
1213 var dragAllowedAxises = _this.getDragAllowedAxises(_this.scale);
1214 $image
1215 .css('width', $image.get().naturalWidth + 'px')
1216 .css('height', $image.get().naturalHeight + 'px');
1217 _this.core.outer.addClass('lg-actual-size');
1218 if (dragAllowedAxises.allowX && dragAllowedAxises.allowY) {
1219 $image.addClass('reset-transition');
1220 }
1221 else if (dragAllowedAxises.allowX &&
1222 !dragAllowedAxises.allowY) {
1223 $image.addClass('reset-transition-x');
1224 }
1225 else if (!dragAllowedAxises.allowX &&
1226 dragAllowedAxises.allowY) {
1227 $image.addClass('reset-transition-y');
1228 }
1229 }
1230 }, ZOOM_TRANSITION_DURATION + 50);
1231 };
1232 /**
1233 * @desc apply scale3d to image and translate to image wrap
1234 * @param {style} X,Y and scale
1235 */
1236 Zoom.prototype.setZoomStyles = function (style) {
1237 var $imageWrap = this.core
1238 .getSlideItem(this.core.index)
1239 .find('.lg-img-wrap')
1240 .first();
1241 var $image = this.core
1242 .getSlideItem(this.core.index)
1243 .find('.lg-image')
1244 .first();
1245 var $dummyImage = this.core.outer
1246 .find('.lg-current .lg-dummy-img')
1247 .first();
1248 this.scale = style.scale;
1249 $image.css('transform', 'scale3d(' + style.scale + ', ' + style.scale + ', 1)');
1250 $dummyImage.css('transform', 'scale3d(' + style.scale + ', ' + style.scale + ', 1)');
1251 var transform = 'translate3d(' + style.x + 'px, ' + style.y + 'px, 0)';
1252 $imageWrap.css('transform', transform);
1253 };
1254 /**
1255 * @param index - Index of the current slide
1256 * @param event - event will be available only if the function is called on clicking/taping the imags
1257 */
1258 Zoom.prototype.setActualSize = function (index, event) {
1259 var _this = this;
1260 var currentItem = this.core.galleryItems[this.core.index];
1261 this.resetImageTranslate(index);
1262 setTimeout(function () {
1263 // Allow zoom only on image
1264 if (!currentItem.src ||
1265 _this.core.outer.hasClass('lg-first-slide-loading')) {
1266 return;
1267 }
1268 var scale = _this.getCurrentImageActualSizeScale();
1269 var prevScale = _this.scale;
1270 if (_this.core.outer.hasClass('lg-zoomed')) {
1271 _this.scale = 1;
1272 }
1273 else {
1274 _this.scale = _this.getScale(scale);
1275 }
1276 _this.setPageCords(event);
1277 _this.beginZoom(_this.scale);
1278 _this.zoomImage(_this.scale, _this.scale - prevScale, true, true);
1279 setTimeout(function () {
1280 _this.core.outer.removeClass('lg-grabbing').addClass('lg-grab');
1281 }, 10);
1282 }, 50);
1283 };
1284 Zoom.prototype.getNaturalWidth = function (index) {
1285 var $image = this.core.getSlideItem(index).find('.lg-image').first();
1286 var naturalWidth = this.core.galleryItems[index].width;
1287 return naturalWidth
1288 ? parseFloat(naturalWidth)
1289 : $image.get().naturalWidth;
1290 };
1291 Zoom.prototype.getActualSizeScale = function (naturalWidth, width) {
1292 var _scale;
1293 var scale;
1294 if (naturalWidth >= width) {
1295 _scale = naturalWidth / width;
1296 scale = _scale || 2;
1297 }
1298 else {
1299 scale = 1;
1300 }
1301 return scale;
1302 };
1303 Zoom.prototype.getCurrentImageActualSizeScale = function () {
1304 var $image = this.core
1305 .getSlideItem(this.core.index)
1306 .find('.lg-image')
1307 .first();
1308 var width = $image.get().offsetWidth;
1309 var naturalWidth = this.getNaturalWidth(this.core.index) || width;
1310 return this.getActualSizeScale(naturalWidth, width);
1311 };
1312 Zoom.prototype.getPageCords = function (event) {
1313 var cords = {};
1314 if (event) {
1315 cords.x = event.pageX || event.touches[0].pageX;
1316 cords.y = event.pageY || event.touches[0].pageY;
1317 }
1318 else {
1319 var containerRect = this.core.$content
1320 .get()
1321 .getBoundingClientRect();
1322 cords.x = containerRect.width / 2 + containerRect.left;
1323 cords.y =
1324 containerRect.height / 2 + this.scrollTop + containerRect.top;
1325 }
1326 return cords;
1327 };
1328 Zoom.prototype.setPageCords = function (event) {
1329 var pageCords = this.getPageCords(event);
1330 this.pageX = pageCords.x;
1331 this.pageY = pageCords.y;
1332 };
1333 Zoom.prototype.manageActualPixelClassNames = function () {
1334 var $actualSize = this.core.getElementById('lg-actual-size');
1335 $actualSize
1336 .removeClass(this.settings.actualSizeIcons.zoomIn)
1337 .addClass(this.settings.actualSizeIcons.zoomOut);
1338 };
1339 // If true, zoomed - in else zoomed out
1340 Zoom.prototype.beginZoom = function (scale) {
1341 this.core.outer.removeClass('lg-zoom-drag-transition lg-zoom-dragging');
1342 if (scale > 1) {
1343 this.core.outer.addClass('lg-zoomed');
1344 this.manageActualPixelClassNames();
1345 }
1346 else {
1347 this.resetZoom();
1348 }
1349 return scale > 1;
1350 };
1351 Zoom.prototype.getScale = function (scale) {
1352 var actualSizeScale = this.getCurrentImageActualSizeScale();
1353 if (scale < 1) {
1354 scale = 1;
1355 }
1356 else if (scale > actualSizeScale) {
1357 scale = actualSizeScale;
1358 }
1359 return scale;
1360 };
1361 Zoom.prototype.init = function () {
1362 var _this = this;
1363 if (!this.settings.zoom) {
1364 return;
1365 }
1366 this.buildTemplates();
1367 this.enableZoomOnSlideItemLoad();
1368 var tapped = null;
1369 this.core.outer.on('dblclick.lg', function (event) {
1370 if (!_this.$LG(event.target).hasClass('lg-image')) {
1371 return;
1372 }
1373 _this.setActualSize(_this.core.index, event);
1374 });
1375 this.core.outer.on('touchstart.lg', function (event) {
1376 var $target = _this.$LG(event.target);
1377 if (event.touches.length === 1 && $target.hasClass('lg-image')) {
1378 if (!tapped) {
1379 tapped = setTimeout(function () {
1380 tapped = null;
1381 }, 300);
1382 }
1383 else {
1384 clearTimeout(tapped);
1385 tapped = null;
1386 event.preventDefault();
1387 _this.setActualSize(_this.core.index, event);
1388 }
1389 }
1390 });
1391 this.core.LGel.on(lGEvents.containerResize + ".zoom " + lGEvents.rotateRight + ".zoom " + lGEvents.rotateLeft + ".zoom " + lGEvents.flipHorizontal + ".zoom " + lGEvents.flipVertical + ".zoom", function () {
1392 if (!_this.core.lgOpened ||
1393 !_this.isImageSlide(_this.core.index) ||
1394 _this.core.touchAction) {
1395 return;
1396 }
1397 var _LGel = _this.core
1398 .getSlideItem(_this.core.index)
1399 .find('.lg-img-wrap')
1400 .first();
1401 _this.top = 0;
1402 _this.left = 0;
1403 _this.setZoomEssentials();
1404 _this.setZoomSwipeStyles(_LGel, { x: 0, y: 0 });
1405 _this.positionChanged = true;
1406 });
1407 // Update zoom on resize and orientationchange
1408 this.$LG(window).on("scroll.lg.zoom.global" + this.core.lgId, function () {
1409 if (!_this.core.lgOpened)
1410 return;
1411 _this.scrollTop = _this.$LG(window).scrollTop();
1412 });
1413 this.core.getElementById('lg-zoom-out').on('click.lg', function () {
1414 // Allow zoom only on image
1415 if (!_this.isImageSlide(_this.core.index)) {
1416 return;
1417 }
1418 var timeout = 0;
1419 if (_this.imageReset) {
1420 _this.resetImageTranslate(_this.core.index);
1421 timeout = 50;
1422 }
1423 setTimeout(function () {
1424 var scale = _this.scale - _this.settings.scale;
1425 if (scale < 1) {
1426 scale = 1;
1427 }
1428 _this.beginZoom(scale);
1429 _this.zoomImage(scale, -_this.settings.scale, true, true);
1430 }, timeout);
1431 });
1432 this.core.getElementById('lg-zoom-in').on('click.lg', function () {
1433 _this.zoomIn();
1434 });
1435 this.core.getElementById('lg-actual-size').on('click.lg', function () {
1436 _this.setActualSize(_this.core.index);
1437 });
1438 this.core.LGel.on(lGEvents.beforeOpen + ".zoom", function () {
1439 _this.core.outer.find('.lg-item').removeClass('lg-zoomable');
1440 });
1441 this.core.LGel.on(lGEvents.afterOpen + ".zoom", function () {
1442 _this.scrollTop = _this.$LG(window).scrollTop();
1443 // Set the initial value center
1444 _this.pageX = _this.core.outer.width() / 2;
1445 _this.pageY = _this.core.outer.height() / 2 + _this.scrollTop;
1446 _this.scale = 1;
1447 });
1448 // Reset zoom on slide change
1449 this.core.LGel.on(lGEvents.afterSlide + ".zoom", function (event) {
1450 var prevIndex = event.detail.prevIndex;
1451 _this.scale = 1;
1452 _this.positionChanged = false;
1453 _this.resetZoom(prevIndex);
1454 _this.resetImageTranslate(prevIndex);
1455 if (_this.isImageSlide(_this.core.index)) {
1456 _this.setZoomEssentials();
1457 }
1458 });
1459 // Drag option after zoom
1460 this.zoomDrag();
1461 this.pinchZoom();
1462 this.zoomSwipe();
1463 // Store the zoomable timeout value just to clear it while closing
1464 this.zoomableTimeout = false;
1465 this.positionChanged = false;
1466 };
1467 Zoom.prototype.zoomIn = function () {
1468 // Allow zoom only on image
1469 if (!this.isImageSlide(this.core.index)) {
1470 return;
1471 }
1472 var scale = this.scale + this.settings.scale;
1473 scale = this.getScale(scale);
1474 this.beginZoom(scale);
1475 this.zoomImage(scale, Math.min(this.settings.scale, scale - this.scale), true, true);
1476 };
1477 // Reset zoom effect
1478 Zoom.prototype.resetZoom = function (index) {
1479 this.core.outer.removeClass('lg-zoomed lg-zoom-drag-transition');
1480 var $actualSize = this.core.getElementById('lg-actual-size');
1481 var $item = this.core.getSlideItem(index !== undefined ? index : this.core.index);
1482 $actualSize
1483 .removeClass(this.settings.actualSizeIcons.zoomOut)
1484 .addClass(this.settings.actualSizeIcons.zoomIn);
1485 $item.find('.lg-img-wrap').first().removeAttr('style');
1486 $item.find('.lg-image').first().removeAttr('style');
1487 this.scale = 1;
1488 this.left = 0;
1489 this.top = 0;
1490 // Reset pagx pagy values to center
1491 this.setPageCords();
1492 };
1493 Zoom.prototype.getTouchDistance = function (e) {
1494 return Math.sqrt((e.touches[0].pageX - e.touches[1].pageX) *
1495 (e.touches[0].pageX - e.touches[1].pageX) +
1496 (e.touches[0].pageY - e.touches[1].pageY) *
1497 (e.touches[0].pageY - e.touches[1].pageY));
1498 };
1499 Zoom.prototype.pinchZoom = function () {
1500 var _this = this;
1501 var startDist = 0;
1502 var pinchStarted = false;
1503 var initScale = 1;
1504 var prevScale = 0;
1505 var $item = this.core.getSlideItem(this.core.index);
1506 this.core.outer.on('touchstart.lg', function (e) {
1507 $item = _this.core.getSlideItem(_this.core.index);
1508 if (!_this.isImageSlide(_this.core.index)) {
1509 return;
1510 }
1511 if (e.touches.length === 2) {
1512 e.preventDefault();
1513 if (_this.core.outer.hasClass('lg-first-slide-loading')) {
1514 return;
1515 }
1516 initScale = _this.scale || 1;
1517 _this.core.outer.removeClass('lg-zoom-drag-transition lg-zoom-dragging');
1518 _this.setPageCords(e);
1519 _this.resetImageTranslate(_this.core.index);
1520 _this.core.touchAction = 'pinch';
1521 startDist = _this.getTouchDistance(e);
1522 }
1523 });
1524 this.core.$inner.on('touchmove.lg', function (e) {
1525 if (e.touches.length === 2 &&
1526 _this.core.touchAction === 'pinch' &&
1527 (_this.$LG(e.target).hasClass('lg-item') ||
1528 $item.get().contains(e.target))) {
1529 e.preventDefault();
1530 var endDist = _this.getTouchDistance(e);
1531 var distance = startDist - endDist;
1532 if (!pinchStarted && Math.abs(distance) > 5) {
1533 pinchStarted = true;
1534 }
1535 if (pinchStarted) {
1536 prevScale = _this.scale;
1537 var _scale = Math.max(1, initScale + -distance * 0.02);
1538 _this.scale =
1539 Math.round((_scale + Number.EPSILON) * 100) / 100;
1540 var diff = _this.scale - prevScale;
1541 _this.zoomImage(_this.scale, Math.round((diff + Number.EPSILON) * 100) / 100, false, false);
1542 }
1543 }
1544 });
1545 this.core.$inner.on('touchend.lg', function (e) {
1546 if (_this.core.touchAction === 'pinch' &&
1547 (_this.$LG(e.target).hasClass('lg-item') ||
1548 $item.get().contains(e.target))) {
1549 pinchStarted = false;
1550 startDist = 0;
1551 if (_this.scale <= 1) {
1552 _this.resetZoom();
1553 }
1554 else {
1555 var actualSizeScale = _this.getCurrentImageActualSizeScale();
1556 if (_this.scale >= actualSizeScale) {
1557 var scaleDiff = actualSizeScale - _this.scale;
1558 if (scaleDiff === 0) {
1559 scaleDiff = 0.01;
1560 }
1561 _this.zoomImage(actualSizeScale, scaleDiff, false, true);
1562 }
1563 _this.manageActualPixelClassNames();
1564 _this.core.outer.addClass('lg-zoomed');
1565 }
1566 _this.core.touchAction = undefined;
1567 }
1568 });
1569 };
1570 Zoom.prototype.touchendZoom = function (startCoords, endCoords, allowX, allowY, touchDuration) {
1571 var distanceXnew = endCoords.x - startCoords.x;
1572 var distanceYnew = endCoords.y - startCoords.y;
1573 var speedX = Math.abs(distanceXnew) / touchDuration + 1;
1574 var speedY = Math.abs(distanceYnew) / touchDuration + 1;
1575 if (speedX > 2) {
1576 speedX += 1;
1577 }
1578 if (speedY > 2) {
1579 speedY += 1;
1580 }
1581 distanceXnew = distanceXnew * speedX;
1582 distanceYnew = distanceYnew * speedY;
1583 var _LGel = this.core
1584 .getSlideItem(this.core.index)
1585 .find('.lg-img-wrap')
1586 .first();
1587 var distance = {};
1588 distance.x = this.left + distanceXnew;
1589 distance.y = this.top + distanceYnew;
1590 var possibleSwipeCords = this.getPossibleSwipeDragCords();
1591 if (Math.abs(distanceXnew) > 15 || Math.abs(distanceYnew) > 15) {
1592 if (allowY) {
1593 if (this.isBeyondPossibleTop(distance.y, possibleSwipeCords.minY)) {
1594 distance.y = possibleSwipeCords.minY;
1595 }
1596 else if (this.isBeyondPossibleBottom(distance.y, possibleSwipeCords.maxY)) {
1597 distance.y = possibleSwipeCords.maxY;
1598 }
1599 }
1600 if (allowX) {
1601 if (this.isBeyondPossibleLeft(distance.x, possibleSwipeCords.minX)) {
1602 distance.x = possibleSwipeCords.minX;
1603 }
1604 else if (this.isBeyondPossibleRight(distance.x, possibleSwipeCords.maxX)) {
1605 distance.x = possibleSwipeCords.maxX;
1606 }
1607 }
1608 if (allowY) {
1609 this.top = distance.y;
1610 }
1611 else {
1612 distance.y = this.top;
1613 }
1614 if (allowX) {
1615 this.left = distance.x;
1616 }
1617 else {
1618 distance.x = this.left;
1619 }
1620 this.setZoomSwipeStyles(_LGel, distance);
1621 this.positionChanged = true;
1622 }
1623 };
1624 Zoom.prototype.getZoomSwipeCords = function (startCoords, endCoords, allowX, allowY, possibleSwipeCords) {
1625 var distance = {};
1626 if (allowY) {
1627 distance.y = this.top + (endCoords.y - startCoords.y);
1628 if (this.isBeyondPossibleTop(distance.y, possibleSwipeCords.minY)) {
1629 var diffMinY = possibleSwipeCords.minY - distance.y;
1630 distance.y = possibleSwipeCords.minY - diffMinY / 6;
1631 }
1632 else if (this.isBeyondPossibleBottom(distance.y, possibleSwipeCords.maxY)) {
1633 var diffMaxY = distance.y - possibleSwipeCords.maxY;
1634 distance.y = possibleSwipeCords.maxY + diffMaxY / 6;
1635 }
1636 }
1637 else {
1638 distance.y = this.top;
1639 }
1640 if (allowX) {
1641 distance.x = this.left + (endCoords.x - startCoords.x);
1642 if (this.isBeyondPossibleLeft(distance.x, possibleSwipeCords.minX)) {
1643 var diffMinX = possibleSwipeCords.minX - distance.x;
1644 distance.x = possibleSwipeCords.minX - diffMinX / 6;
1645 }
1646 else if (this.isBeyondPossibleRight(distance.x, possibleSwipeCords.maxX)) {
1647 var difMaxX = distance.x - possibleSwipeCords.maxX;
1648 distance.x = possibleSwipeCords.maxX + difMaxX / 6;
1649 }
1650 }
1651 else {
1652 distance.x = this.left;
1653 }
1654 return distance;
1655 };
1656 Zoom.prototype.isBeyondPossibleLeft = function (x, minX) {
1657 return x >= minX;
1658 };
1659 Zoom.prototype.isBeyondPossibleRight = function (x, maxX) {
1660 return x <= maxX;
1661 };
1662 Zoom.prototype.isBeyondPossibleTop = function (y, minY) {
1663 return y >= minY;
1664 };
1665 Zoom.prototype.isBeyondPossibleBottom = function (y, maxY) {
1666 return y <= maxY;
1667 };
1668 Zoom.prototype.isImageSlide = function (index) {
1669 var currentItem = this.core.galleryItems[index];
1670 return this.core.getSlideType(currentItem) === 'image';
1671 };
1672 Zoom.prototype.getPossibleSwipeDragCords = function (scale) {
1673 var $image = this.core
1674 .getSlideItem(this.core.index)
1675 .find('.lg-image')
1676 .first();
1677 var bottom = this.core.mediaContainerPosition.bottom;
1678 var imgRect = $image.get().getBoundingClientRect();
1679 var imageHeight = imgRect.height;
1680 var imageWidth = imgRect.width;
1681 if (scale) {
1682 imageHeight = imageHeight + scale * imageHeight;
1683 imageWidth = imageWidth + scale * imageWidth;
1684 }
1685 var minY = (imageHeight - this.containerRect.height) / 2;
1686 var maxY = (this.containerRect.height - imageHeight) / 2 + bottom;
1687 var minX = (imageWidth - this.containerRect.width) / 2;
1688 var maxX = (this.containerRect.width - imageWidth) / 2;
1689 var possibleSwipeCords = {
1690 minY: minY,
1691 maxY: maxY,
1692 minX: minX,
1693 maxX: maxX,
1694 };
1695 return possibleSwipeCords;
1696 };
1697 Zoom.prototype.setZoomSwipeStyles = function (LGel, distance) {
1698 LGel.css('transform', 'translate3d(' + distance.x + 'px, ' + distance.y + 'px, 0)');
1699 };
1700 Zoom.prototype.zoomSwipe = function () {
1701 var _this = this;
1702 var startCoords = {};
1703 var endCoords = {};
1704 var isMoved = false;
1705 // Allow x direction drag
1706 var allowX = false;
1707 // Allow Y direction drag
1708 var allowY = false;
1709 var startTime = new Date();
1710 var endTime = new Date();
1711 var possibleSwipeCords;
1712 var _LGel;
1713 var $item = this.core.getSlideItem(this.core.index);
1714 this.core.$inner.on('touchstart.lg', function (e) {
1715 // Allow zoom only on image
1716 if (!_this.isImageSlide(_this.core.index)) {
1717 return;
1718 }
1719 $item = _this.core.getSlideItem(_this.core.index);
1720 if ((_this.$LG(e.target).hasClass('lg-item') ||
1721 $item.get().contains(e.target)) &&
1722 e.touches.length === 1 &&
1723 _this.core.outer.hasClass('lg-zoomed')) {
1724 e.preventDefault();
1725 startTime = new Date();
1726 _this.core.touchAction = 'zoomSwipe';
1727 _LGel = _this.core
1728 .getSlideItem(_this.core.index)
1729 .find('.lg-img-wrap')
1730 .first();
1731 var dragAllowedAxises = _this.getDragAllowedAxises(0);
1732 allowY = dragAllowedAxises.allowY;
1733 allowX = dragAllowedAxises.allowX;
1734 if (allowX || allowY) {
1735 startCoords = _this.getSwipeCords(e);
1736 }
1737 possibleSwipeCords = _this.getPossibleSwipeDragCords();
1738 // reset opacity and transition duration
1739 _this.core.outer.addClass('lg-zoom-dragging lg-zoom-drag-transition');
1740 }
1741 });
1742 this.core.$inner.on('touchmove.lg', function (e) {
1743 if (e.touches.length === 1 &&
1744 _this.core.touchAction === 'zoomSwipe' &&
1745 (_this.$LG(e.target).hasClass('lg-item') ||
1746 $item.get().contains(e.target))) {
1747 e.preventDefault();
1748 _this.core.touchAction = 'zoomSwipe';
1749 endCoords = _this.getSwipeCords(e);
1750 var distance = _this.getZoomSwipeCords(startCoords, endCoords, allowX, allowY, possibleSwipeCords);
1751 if (Math.abs(endCoords.x - startCoords.x) > 15 ||
1752 Math.abs(endCoords.y - startCoords.y) > 15) {
1753 isMoved = true;
1754 _this.setZoomSwipeStyles(_LGel, distance);
1755 }
1756 }
1757 });
1758 this.core.$inner.on('touchend.lg', function (e) {
1759 if (_this.core.touchAction === 'zoomSwipe' &&
1760 (_this.$LG(e.target).hasClass('lg-item') ||
1761 $item.get().contains(e.target))) {
1762 e.preventDefault();
1763 _this.core.touchAction = undefined;
1764 _this.core.outer.removeClass('lg-zoom-dragging');
1765 if (!isMoved) {
1766 return;
1767 }
1768 isMoved = false;
1769 endTime = new Date();
1770 var touchDuration = endTime.valueOf() - startTime.valueOf();
1771 _this.touchendZoom(startCoords, endCoords, allowX, allowY, touchDuration);
1772 }
1773 });
1774 };
1775 Zoom.prototype.zoomDrag = function () {
1776 var _this = this;
1777 var startCoords = {};
1778 var endCoords = {};
1779 var isDragging = false;
1780 var isMoved = false;
1781 // Allow x direction drag
1782 var allowX = false;
1783 // Allow Y direction drag
1784 var allowY = false;
1785 var startTime;
1786 var endTime;
1787 var possibleSwipeCords;
1788 var _LGel;
1789 this.core.outer.on('mousedown.lg.zoom', function (e) {
1790 // Allow zoom only on image
1791 if (!_this.isImageSlide(_this.core.index)) {
1792 return;
1793 }
1794 var $item = _this.core.getSlideItem(_this.core.index);
1795 if (_this.$LG(e.target).hasClass('lg-item') ||
1796 $item.get().contains(e.target)) {
1797 startTime = new Date();
1798 _LGel = _this.core
1799 .getSlideItem(_this.core.index)
1800 .find('.lg-img-wrap')
1801 .first();
1802 var dragAllowedAxises = _this.getDragAllowedAxises(0);
1803 allowY = dragAllowedAxises.allowY;
1804 allowX = dragAllowedAxises.allowX;
1805 if (_this.core.outer.hasClass('lg-zoomed')) {
1806 if (_this.$LG(e.target).hasClass('lg-object') &&
1807 (allowX || allowY)) {
1808 e.preventDefault();
1809 startCoords = _this.getDragCords(e);
1810 possibleSwipeCords = _this.getPossibleSwipeDragCords();
1811 isDragging = true;
1812 _this.core.outer
1813 .removeClass('lg-grab')
1814 .addClass('lg-grabbing lg-zoom-drag-transition lg-zoom-dragging');
1815 // reset opacity and transition duration
1816 }
1817 }
1818 }
1819 });
1820 this.$LG(window).on("mousemove.lg.zoom.global" + this.core.lgId, function (e) {
1821 if (isDragging) {
1822 isMoved = true;
1823 endCoords = _this.getDragCords(e);
1824 var distance = _this.getZoomSwipeCords(startCoords, endCoords, allowX, allowY, possibleSwipeCords);
1825 _this.setZoomSwipeStyles(_LGel, distance);
1826 }
1827 });
1828 this.$LG(window).on("mouseup.lg.zoom.global" + this.core.lgId, function (e) {
1829 if (isDragging) {
1830 endTime = new Date();
1831 isDragging = false;
1832 _this.core.outer.removeClass('lg-zoom-dragging');
1833 // Fix for chrome mouse move on click
1834 if (isMoved &&
1835 (startCoords.x !== endCoords.x ||
1836 startCoords.y !== endCoords.y)) {
1837 endCoords = _this.getDragCords(e);
1838 var touchDuration = endTime.valueOf() - startTime.valueOf();
1839 _this.touchendZoom(startCoords, endCoords, allowX, allowY, touchDuration);
1840 }
1841 isMoved = false;
1842 }
1843 _this.core.outer.removeClass('lg-grabbing').addClass('lg-grab');
1844 });
1845 };
1846 Zoom.prototype.closeGallery = function () {
1847 this.resetZoom();
1848 };
1849 Zoom.prototype.destroy = function () {
1850 // Unbind all events added by lightGallery zoom plugin
1851 this.$LG(window).off(".lg.zoom.global" + this.core.lgId);
1852 this.core.LGel.off('.lg.zoom');
1853 this.core.LGel.off('.zoom');
1854 clearTimeout(this.zoomableTimeout);
1855 this.zoomableTimeout = false;
1856 };
1857 return Zoom;
1858 }());
1859
1860 return Zoom;
1861
1862 })));
1863
1864
1865