lg-medium-zoom.umd.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*!
  2. * lightgallery | 2.4.0-beta.0 | December 12th 2021
  3. * http://www.lightgalleryjs.com/
  4. * Copyright (c) 2020 Sachin Neravath;
  5. * @license GPLv3
  6. */
  7. (function (global, factory) {
  8. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  9. typeof define === 'function' && define.amd ? define(factory) :
  10. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.lgMediumZoom = factory());
  11. }(this, (function () { 'use strict';
  12. /*! *****************************************************************************
  13. Copyright (c) Microsoft Corporation.
  14. Permission to use, copy, modify, and/or distribute this software for any
  15. purpose with or without fee is hereby granted.
  16. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  17. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  18. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  19. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  20. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  21. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  22. PERFORMANCE OF THIS SOFTWARE.
  23. ***************************************************************************** */
  24. var __assign = function() {
  25. __assign = Object.assign || function __assign(t) {
  26. for (var s, i = 1, n = arguments.length; i < n; i++) {
  27. s = arguments[i];
  28. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  29. }
  30. return t;
  31. };
  32. return __assign.apply(this, arguments);
  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. * */
  39. var 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. var mediumZoomSettings = {
  68. margin: 40,
  69. mediumZoom: true,
  70. backgroundColor: '#000',
  71. };
  72. var MediumZoom = /** @class */ (function () {
  73. function MediumZoom(instance, $LG) {
  74. var _this = this;
  75. // get lightGallery core plugin instance
  76. this.core = instance;
  77. this.$LG = $LG;
  78. // Set margin
  79. this.core.getMediaContainerPosition = function () {
  80. return {
  81. top: _this.settings.margin,
  82. bottom: _this.settings.margin,
  83. };
  84. };
  85. // Override some of lightGallery default settings
  86. var defaultSettings = {
  87. controls: false,
  88. download: false,
  89. counter: false,
  90. showCloseIcon: false,
  91. extraProps: ['lgBackgroundColor'],
  92. closeOnTap: false,
  93. enableSwipe: false,
  94. enableDrag: false,
  95. swipeToClose: false,
  96. addClass: this.core.settings.addClass + ' lg-medium-zoom',
  97. };
  98. this.core.settings = __assign(__assign({}, this.core.settings), defaultSettings);
  99. // extend module default settings with lightGallery core settings
  100. this.settings = __assign(__assign(__assign({}, mediumZoomSettings), this.core.settings), defaultSettings);
  101. return this;
  102. }
  103. MediumZoom.prototype.toggleItemClass = function () {
  104. for (var index = 0; index < this.core.items.length; index++) {
  105. var $element = this.$LG(this.core.items[index]);
  106. $element.toggleClass('lg-medium-zoom-item');
  107. }
  108. };
  109. MediumZoom.prototype.init = function () {
  110. var _this = this;
  111. if (!this.settings.mediumZoom) {
  112. return;
  113. }
  114. this.core.LGel.on(lGEvents.beforeOpen + ".medium", function () {
  115. _this.core.$backdrop.css('background-color', _this.core.galleryItems[_this.core.index].lgBackgroundColor ||
  116. _this.settings.backgroundColor);
  117. });
  118. this.toggleItemClass();
  119. this.core.outer.on('click.lg.medium', function () {
  120. _this.core.closeGallery();
  121. });
  122. };
  123. MediumZoom.prototype.destroy = function () {
  124. this.toggleItemClass();
  125. };
  126. return MediumZoom;
  127. }());
  128. return MediumZoom;
  129. })));
  130. //# sourceMappingURL=lg-medium-zoom.umd.js.map