lg-medium-zoom.es5.js 4.7 KB

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