lightgallery 2.3.0-beta.1 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/css/lightgallery-bundle.css +19 -26
  2. package/css/lightgallery-bundle.min.css +1 -1
  3. package/css/lightgallery-core.css +0 -19
  4. package/css/lightgallery.css +19 -26
  5. package/lg-events.d.ts +0 -4
  6. package/lg-settings.d.ts +17 -8
  7. package/lg-utils.d.ts +25 -4
  8. package/lib/lg-settings.js +4 -2
  9. package/lib/lg-settings.js.map +1 -1
  10. package/lib/lg-utils.js +45 -5
  11. package/lib/lg-utils.js.map +1 -1
  12. package/lib/lgQuery.js +31 -20
  13. package/lib/lgQuery.js.map +1 -1
  14. package/lib/lightgallery.js +113 -119
  15. package/lib/lightgallery.js.map +1 -1
  16. package/lib/plugins/video/lg-video-settings.js.map +1 -1
  17. package/lib/plugins/video/lg-video-utils.js +24 -0
  18. package/lib/plugins/video/lg-video-utils.js.map +1 -0
  19. package/lib/plugins/video/lg-video.js +37 -31
  20. package/lib/plugins/video/lg-video.js.map +1 -1
  21. package/lib/plugins/zoom/lg-zoom.js +7 -8
  22. package/lib/plugins/zoom/lg-zoom.js.map +1 -1
  23. package/lightgallery.d.ts +18 -10
  24. package/lightgallery.es5.js +194 -147
  25. package/lightgallery.es5.js.map +1 -1
  26. package/lightgallery.min.js +2 -2
  27. package/lightgallery.umd.js +194 -147
  28. package/lightgallery.umd.js.map +1 -1
  29. package/lit/lightgallery.esm.js +7 -7
  30. package/lit/lightgallery.umd.js +3 -3
  31. package/package.json +1 -1
  32. package/plugins/autoplay/lg-autoplay.es5.js +1 -1
  33. package/plugins/autoplay/lg-autoplay.es5.js.map +1 -1
  34. package/plugins/autoplay/lg-autoplay.min.js +1 -1
  35. package/plugins/autoplay/lg-autoplay.umd.js +1 -1
  36. package/plugins/autoplay/lg-autoplay.umd.js.map +1 -1
  37. package/plugins/comment/lg-comment.es5.js +1 -1
  38. package/plugins/comment/lg-comment.es5.js.map +1 -1
  39. package/plugins/comment/lg-comment.min.js +1 -1
  40. package/plugins/comment/lg-comment.umd.js +1 -1
  41. package/plugins/comment/lg-comment.umd.js.map +1 -1
  42. package/plugins/fullscreen/lg-fullscreen.es5.js +1 -1
  43. package/plugins/fullscreen/lg-fullscreen.min.js +1 -1
  44. package/plugins/fullscreen/lg-fullscreen.umd.js +1 -1
  45. package/plugins/hash/lg-hash.es5.js +1 -1
  46. package/plugins/hash/lg-hash.es5.js.map +1 -1
  47. package/plugins/hash/lg-hash.min.js +1 -1
  48. package/plugins/hash/lg-hash.umd.js +1 -1
  49. package/plugins/hash/lg-hash.umd.js.map +1 -1
  50. package/plugins/mediumZoom/lg-medium-zoom.es5.js +1 -1
  51. package/plugins/mediumZoom/lg-medium-zoom.es5.js.map +1 -1
  52. package/plugins/mediumZoom/lg-medium-zoom.min.js +1 -1
  53. package/plugins/mediumZoom/lg-medium-zoom.umd.js +1 -1
  54. package/plugins/mediumZoom/lg-medium-zoom.umd.js.map +1 -1
  55. package/plugins/pager/lg-pager.es5.js +1 -1
  56. package/plugins/pager/lg-pager.es5.js.map +1 -1
  57. package/plugins/pager/lg-pager.min.js +1 -1
  58. package/plugins/pager/lg-pager.umd.js +1 -1
  59. package/plugins/pager/lg-pager.umd.js.map +1 -1
  60. package/plugins/relativeCaption/lg-relative-caption.es5.js +1 -1
  61. package/plugins/relativeCaption/lg-relative-caption.es5.js.map +1 -1
  62. package/plugins/relativeCaption/lg-relative-caption.min.js +1 -1
  63. package/plugins/relativeCaption/lg-relative-caption.umd.js +1 -1
  64. package/plugins/relativeCaption/lg-relative-caption.umd.js.map +1 -1
  65. package/plugins/rotate/lg-rotate.es5.js +1 -1
  66. package/plugins/rotate/lg-rotate.es5.js.map +1 -1
  67. package/plugins/rotate/lg-rotate.min.js +1 -1
  68. package/plugins/rotate/lg-rotate.umd.js +1 -1
  69. package/plugins/rotate/lg-rotate.umd.js.map +1 -1
  70. package/plugins/share/lg-share.es5.js +1 -1
  71. package/plugins/share/lg-share.es5.js.map +1 -1
  72. package/plugins/share/lg-share.min.js +1 -1
  73. package/plugins/share/lg-share.umd.js +1 -1
  74. package/plugins/share/lg-share.umd.js.map +1 -1
  75. package/plugins/thumbnail/lg-thumbnail.es5.js +1 -1
  76. package/plugins/thumbnail/lg-thumbnail.es5.js.map +1 -1
  77. package/plugins/thumbnail/lg-thumbnail.min.js +1 -1
  78. package/plugins/thumbnail/lg-thumbnail.umd.js +1 -1
  79. package/plugins/thumbnail/lg-thumbnail.umd.js.map +1 -1
  80. package/plugins/video/lg-video-settings.d.ts +2 -1
  81. package/plugins/video/lg-video-utils.d.ts +6 -0
  82. package/plugins/video/lg-video.d.ts +6 -1
  83. package/plugins/video/lg-video.es5.js +56 -30
  84. package/plugins/video/lg-video.es5.js.map +1 -1
  85. package/plugins/video/lg-video.min.js +2 -2
  86. package/plugins/video/lg-video.umd.js +56 -30
  87. package/plugins/video/lg-video.umd.js.map +1 -1
  88. package/plugins/zoom/lg-zoom.es5.js +8 -9
  89. package/plugins/zoom/lg-zoom.es5.js.map +1 -1
  90. package/plugins/zoom/lg-zoom.min.js +2 -2
  91. package/plugins/zoom/lg-zoom.umd.js +8 -9
  92. package/plugins/zoom/lg-zoom.umd.js.map +1 -1
  93. package/react/Lightgallery.es5.js +194 -147
  94. package/react/Lightgallery.es5.js.map +1 -1
  95. package/react/Lightgallery.umd.js +194 -147
  96. package/react/Lightgallery.umd.js.map +1 -1
  97. package/scss/_lg-theme-default.scss +17 -10
  98. package/scss/lightgallery-core.scss +0 -24
  99. package/vue/LightGalleryVue.common.js +188 -150
  100. package/vue/LightGalleryVue.common.js.map +1 -1
  101. package/vue/LightGalleryVue.umd.js +188 -150
  102. package/vue/LightGalleryVue.umd.js.map +1 -1
  103. package/vue/LightGalleryVue.umd.min.js +2 -2
  104. package/vue/LightGalleryVue.umd.min.js.map +1 -1
@@ -219,16 +219,23 @@
219
219
  body:not(.lg-from-hash) {
220
220
  .lg-outer {
221
221
  &.lg-start-zoom {
222
- .lg-object {
223
- opacity: 0;
224
- will-change: opacity;
225
- @include transitionCustom(
226
- opacity 250ms cubic-bezier(0, 0, 0.25, 1) !important
227
- );
228
- }
229
- .lg-item.lg-complete {
230
- .lg-object {
231
- opacity: 1;
222
+ .lg-item:not(.lg-zoomable) {
223
+ .lg-img-wrap,
224
+ .lg-video-cont {
225
+ opacity: 0;
226
+ @include transform(scale3d(0.5, 0.5, 0.5));
227
+ will-change: transform, opacity;
228
+ @include transitionCustom(
229
+ transform 250ms cubic-bezier(0, 0, 0.25, 1) 0s,
230
+ opacity 250ms cubic-bezier(0, 0, 0.25, 1) !important
231
+ );
232
+ }
233
+ &.lg-complete {
234
+ .lg-img-wrap,
235
+ .lg-video-cont {
236
+ opacity: 1;
237
+ @include transform(scale3d(1, 1, 1));
238
+ }
232
239
  }
233
240
  }
234
241
  }
@@ -221,30 +221,6 @@
221
221
  position: relative;
222
222
  }
223
223
 
224
- &.lg-show-after-load {
225
- .lg-item {
226
- .lg-object,
227
- .lg-video-play-button {
228
- opacity: 0;
229
- will-change: opacity;
230
- @include transition(opacity 0.15s ease 0s);
231
- }
232
- &.lg-zoom-from-image {
233
- .lg-object,
234
- .lg-video-play-button {
235
- opacity: 1;
236
- }
237
- }
238
-
239
- &.lg-complete {
240
- .lg-object,
241
- .lg-video-play-button {
242
- opacity: 1;
243
- }
244
- }
245
- }
246
- }
247
-
248
224
  // Hide title div if empty
249
225
  .lg-empty-html {
250
226
  &.lg-sub-html,
@@ -5805,9 +5805,6 @@ var es_array_concat = __webpack_require__("99af");
5805
5805
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.find.js
5806
5806
  var es_array_find = __webpack_require__("7db0");
5807
5807
 
5808
- // EXTERNAL MODULE: ./node_modules/core-js/modules/es.string.match.js
5809
- var es_string_match = __webpack_require__("466d");
5810
-
5811
5808
  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
5812
5809
  function arrayLikeToArray_arrayLikeToArray(arr, len) {
5813
5810
  if (len == null || len > arr.length) len = arr.length;
@@ -5895,6 +5892,9 @@ var es_array_map = __webpack_require__("d81d");
5895
5892
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.splice.js
5896
5893
  var es_array_splice = __webpack_require__("a434");
5897
5894
 
5895
+ // EXTERNAL MODULE: ./node_modules/core-js/modules/es.string.match.js
5896
+ var es_string_match = __webpack_require__("466d");
5897
+
5898
5898
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.promise.js
5899
5899
  var es_promise = __webpack_require__("e6cf");
5900
5900
 
@@ -5915,28 +5915,30 @@ var es_regexp_to_string = __webpack_require__("25f0");
5915
5915
 
5916
5916
 
5917
5917
 
5918
- (function () {
5919
- if (typeof window.CustomEvent === 'function') return false;
5918
+ function initLgPolyfills() {
5919
+ (function () {
5920
+ if (typeof window.CustomEvent === 'function') return false;
5920
5921
 
5921
- function CustomEvent(event, params) {
5922
- params = params || {
5923
- bubbles: false,
5924
- cancelable: false,
5925
- detail: null
5926
- };
5927
- var evt = document.createEvent('CustomEvent');
5928
- evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
5929
- return evt;
5930
- }
5922
+ function CustomEvent(event, params) {
5923
+ params = params || {
5924
+ bubbles: false,
5925
+ cancelable: false,
5926
+ detail: null
5927
+ };
5928
+ var evt = document.createEvent('CustomEvent');
5929
+ evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
5930
+ return evt;
5931
+ }
5931
5932
 
5932
- window.CustomEvent = CustomEvent;
5933
- })();
5933
+ window.CustomEvent = CustomEvent;
5934
+ })();
5934
5935
 
5935
- (function () {
5936
- if (!Element.prototype.matches) {
5937
- Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
5938
- }
5939
- })();
5936
+ (function () {
5937
+ if (!Element.prototype.matches) {
5938
+ Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
5939
+ }
5940
+ })();
5941
+ }
5940
5942
 
5941
5943
  var lgQuery_lgQuery = /*#__PURE__*/function () {
5942
5944
  function lgQuery(selector) {
@@ -6099,7 +6101,9 @@ var lgQuery_lgQuery = /*#__PURE__*/function () {
6099
6101
  this._each(function (el) {
6100
6102
  // IE doesn't support multiple arguments
6101
6103
  classNames.split(' ').forEach(function (className) {
6102
- el.classList.add(className);
6104
+ if (className) {
6105
+ el.classList.add(className);
6106
+ }
6103
6107
  });
6104
6108
  });
6105
6109
 
@@ -6111,7 +6115,9 @@ var lgQuery_lgQuery = /*#__PURE__*/function () {
6111
6115
  this._each(function (el) {
6112
6116
  // IE doesn't support multiple arguments
6113
6117
  classNames.split(' ').forEach(function (className) {
6114
- el.classList.remove(className);
6118
+ if (className) {
6119
+ el.classList.remove(className);
6120
+ }
6115
6121
  });
6116
6122
  });
6117
6123
 
@@ -6373,6 +6379,7 @@ var lgQuery_lgQuery = /*#__PURE__*/function () {
6373
6379
  }();
6374
6380
  lgQuery_lgQuery.eventListeners = {};
6375
6381
  function $LG(selector) {
6382
+ initLgPolyfills();
6376
6383
  return new lgQuery_lgQuery(selector);
6377
6384
  }
6378
6385
  // CONCATENATED MODULE: ../src/lg-utils.ts
@@ -6389,6 +6396,7 @@ function $LG(selector) {
6389
6396
 
6390
6397
 
6391
6398
 
6399
+
6392
6400
  var defaultDynamicOptions = ['src', 'sources', 'subHtml', 'subHtmlUrl', 'html', 'video', 'poster', 'slideName', 'responsive', 'srcset', 'sizes', 'iframe', 'downloadUrl', 'download', 'width', 'facebookShareUrl', 'tweetText', 'iframeTitle', 'twitterShareUrl', 'pinterestShareUrl', 'pinterestText', 'fbHtml', 'disqusIdentifier', 'disqusUrl']; // Convert html data-attribute to camalcase
6393
6401
 
6394
6402
  function convertToData(attr) {
@@ -6408,15 +6416,13 @@ var utils = {
6408
6416
  /**
6409
6417
  * get possible width and height from the lgSize attribute. Used for ZoomFromOrigin option
6410
6418
  */
6411
- // @todo improive this
6412
6419
  getSize: function getSize(el, container) {
6413
6420
  var spacing = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
6414
- var isDisabled = arguments.length > 3 ? arguments[3] : undefined;
6415
- var defaultLgSize = arguments.length > 4 ? arguments[4] : undefined;
6421
+ var defaultLgSize = arguments.length > 3 ? arguments[3] : undefined;
6416
6422
  var LGel = $LG(el);
6417
6423
  var lgSize = LGel.attr('data-lg-size') || defaultLgSize;
6418
6424
 
6419
- if (!lgSize || isDisabled) {
6425
+ if (!lgSize) {
6420
6426
  return;
6421
6427
  }
6422
6428
 
@@ -6485,9 +6491,9 @@ var utils = {
6485
6491
  var transform = 'translate3d(' + (x *= -1) + 'px, ' + (y *= -1) + 'px, 0) scale3d(' + scX + ', ' + scY + ', 1)';
6486
6492
  return transform;
6487
6493
  },
6488
- getIframeMarkup: function getIframeMarkup(iframeWidth, iframeHeight, src, iframeTitle) {
6494
+ getIframeMarkup: function getIframeMarkup(iframeWidth, iframeHeight, iframeMaxWidth, iframeMaxHeight, src, iframeTitle) {
6489
6495
  var title = iframeTitle ? 'title="' + iframeTitle + '"' : '';
6490
- return "<div class=\"lg-video-cont lg-has-iframe\" style=\"width:".concat(iframeWidth, "; height: ").concat(iframeHeight, "\">\n <iframe class=\"lg-object\" frameborder=\"0\" ").concat(title, " src=\"").concat(src, "\" allowfullscreen=\"true\"></iframe>\n </div>");
6496
+ return "<div class=\"lg-video-cont lg-has-iframe\" style=\"width:".concat(iframeWidth, "; max-width:").concat(iframeMaxWidth, "; height: ").concat(iframeHeight, "; max-height:").concat(iframeMaxHeight, "\">\n <iframe class=\"lg-object\" frameborder=\"0\" ").concat(title, " src=\"").concat(src, "\" allowfullscreen=\"true\"></iframe>\n </div>");
6491
6497
  },
6492
6498
  getImgMarkup: function getImgMarkup(index, src, altAttr, srcset, sizes, sources) {
6493
6499
  var srcsetAttr = srcset ? "srcset=\"".concat(srcset, "\"") : '';
@@ -6618,6 +6624,45 @@ var utils = {
6618
6624
  },
6619
6625
  isMobile: function isMobile() {
6620
6626
  return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
6627
+ },
6628
+
6629
+ /**
6630
+ * @desc Check the given src is video
6631
+ * @param {String} src
6632
+ * @return {Object} video type
6633
+ * Ex:{ youtube : ["//www.youtube.com/watch?v=c0asJgSyxcY", "c0asJgSyxcY"] }
6634
+ *
6635
+ * @todo - this information can be moved to dynamicEl to avoid frequent calls
6636
+ */
6637
+ isVideo: function isVideo(src, isHTML5VIdeo, index) {
6638
+ if (!src) {
6639
+ if (isHTML5VIdeo) {
6640
+ return {
6641
+ html5: true
6642
+ };
6643
+ } else {
6644
+ console.error('lightGallery :- data-src is not provided on slide item ' + (index + 1) + '. Please make sure the selector property is properly configured. More info - https://www.lightgalleryjs.com/demos/html-markup/');
6645
+ return;
6646
+ }
6647
+ }
6648
+
6649
+ var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)([\&|?][\S]*)*/i);
6650
+ var vimeo = src.match(/\/\/(?:www\.)?(?:player\.)?vimeo.com\/(?:video\/)?([0-9a-z\-_]+)(.*)?/i);
6651
+ var wistia = src.match(/https?:\/\/(.+)?(wistia\.com|wi\.st)\/(medias|embed)\/([0-9a-z\-_]+)(.*)/);
6652
+
6653
+ if (youtube) {
6654
+ return {
6655
+ youtube: youtube
6656
+ };
6657
+ } else if (vimeo) {
6658
+ return {
6659
+ vimeo: vimeo
6660
+ };
6661
+ } else if (wistia) {
6662
+ return {
6663
+ wistia: wistia
6664
+ };
6665
+ }
6621
6666
  }
6622
6667
  };
6623
6668
  /* harmony default export */ var lg_utils = (utils);
@@ -6632,7 +6677,7 @@ var lightGalleryCoreSettings = {
6632
6677
  addClass: '',
6633
6678
  startClass: 'lg-start-zoom',
6634
6679
  backdropDuration: 300,
6635
- container: document.body,
6680
+ container: '',
6636
6681
  startAnimationDuration: 400,
6637
6682
  zoomFromOrigin: true,
6638
6683
  hideBarsDelay: 0,
@@ -6641,6 +6686,7 @@ var lightGalleryCoreSettings = {
6641
6686
  supportLegacyBrowser: true,
6642
6687
  allowMediaOverlap: false,
6643
6688
  videoMaxSize: '1280-720',
6689
+ loadYouTubePoster: true,
6644
6690
  defaultCaptionHeight: 0,
6645
6691
  ariaLabelledby: '',
6646
6692
  ariaDescribedby: '',
@@ -6661,7 +6707,6 @@ var lightGalleryCoreSettings = {
6661
6707
  subHtmlSelectorRelative: false,
6662
6708
  preload: 2,
6663
6709
  numberOfSlideItemsInDom: 10,
6664
- showAfterLoad: true,
6665
6710
  selector: '',
6666
6711
  selectWithin: '',
6667
6712
  nextHtml: '',
@@ -6669,6 +6714,8 @@ var lightGalleryCoreSettings = {
6669
6714
  index: 0,
6670
6715
  iframeWidth: '100%',
6671
6716
  iframeHeight: '100%',
6717
+ iframeMaxWidth: '100%',
6718
+ iframeMaxHeight: '100%',
6672
6719
  download: true,
6673
6720
  counter: true,
6674
6721
  appendCounterTo: '.lg-toolbar',
@@ -6730,7 +6777,6 @@ var lGEvents = {
6730
6777
 
6731
6778
 
6732
6779
 
6733
-
6734
6780
  // @ref - https://stackoverflow.com/questions/3971841/how-to-resize-images-proportionally-keeping-the-aspect-ratio
6735
6781
  // @ref - https://2ality.com/2017/04/setting-up-multi-platform-packages.html
6736
6782
  // Unique id for each gallery
@@ -6980,10 +7026,6 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
6980
7026
  outerClassNames += 'lg-grab ';
6981
7027
  }
6982
7028
 
6983
- if (this.settings.showAfterLoad) {
6984
- outerClassNames += 'lg-show-after-load';
6985
- }
6986
-
6987
7029
  this.outer.addClass(outerClassNames);
6988
7030
  this.$inner.css('transition-timing-function', this.settings.easing);
6989
7031
  this.$inner.css('transition-duration', this.settings.speed + 'ms');
@@ -7006,13 +7048,12 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7006
7048
  value: function refreshOnResize() {
7007
7049
  if (this.lgOpened) {
7008
7050
  var currentGalleryItem = this.galleryItems[this.index];
7009
- var __slideVideoInfo = currentGalleryItem.__slideVideoInfo,
7010
- poster = currentGalleryItem.poster;
7051
+ var __slideVideoInfo = currentGalleryItem.__slideVideoInfo;
7011
7052
  this.mediaContainerPosition = this.getMediaContainerPosition();
7012
7053
  var _this$mediaContainerP = this.mediaContainerPosition,
7013
7054
  top = _this$mediaContainerP.top,
7014
7055
  bottom = _this$mediaContainerP.bottom;
7015
- this.currentImageSize = lg_utils.getSize(this.items[this.index], this.outer, top + bottom, __slideVideoInfo && !poster, __slideVideoInfo && this.settings.videoMaxSize);
7056
+ this.currentImageSize = lg_utils.getSize(this.items[this.index], this.outer, top + bottom, __slideVideoInfo && this.settings.videoMaxSize);
7016
7057
 
7017
7058
  if (__slideVideoInfo) {
7018
7059
  this.resizeVideoSlide(this.index, this.currentImageSize);
@@ -7205,12 +7246,10 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7205
7246
  this.setMediaContainerPosition(top, bottom);
7206
7247
  }
7207
7248
 
7208
- var _this$galleryItems$in = this.galleryItems[index],
7209
- __slideVideoInfo = _this$galleryItems$in.__slideVideoInfo,
7210
- poster = _this$galleryItems$in.poster;
7249
+ var __slideVideoInfo = this.galleryItems[index].__slideVideoInfo;
7211
7250
 
7212
7251
  if (this.zoomFromOrigin && element) {
7213
- this.currentImageSize = lg_utils.getSize(element, this.outer, top + bottom, __slideVideoInfo && !poster, __slideVideoInfo && this.settings.videoMaxSize);
7252
+ this.currentImageSize = lg_utils.getSize(element, this.outer, top + bottom, __slideVideoInfo && this.settings.videoMaxSize);
7214
7253
  transform = lg_utils.getTransform(element, this.outer, top, bottom, this.currentImageSize);
7215
7254
  }
7216
7255
 
@@ -7496,7 +7535,7 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7496
7535
  var imgContent = '';
7497
7536
  var altAttr = alt ? 'alt="' + alt + '"' : '';
7498
7537
 
7499
- if (!this.lGalleryOn && this.zoomFromOrigin && this.currentImageSize) {
7538
+ if (this.isFirstSlideWithZoomAnimation()) {
7500
7539
  imgContent = this.getDummyImageContent($currentSlide, index, altAttr);
7501
7540
  } else {
7502
7541
  imgContent = lg_utils.getImgMarkup(index, src, altAttr, srcset, sizes, sources);
@@ -7506,85 +7545,66 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7506
7545
  $currentSlide.prepend(imgMarkup);
7507
7546
  }
7508
7547
  }, {
7509
- key: "onLgObjectLoad",
7510
- value: function onLgObjectLoad($el, index, delay, speed, dummyImageLoaded, isFirstSlide) {
7511
- var _this7 = this;
7548
+ key: "onSlideObjectLoad",
7549
+ value: function onSlideObjectLoad($slide, isHTML5VideoWithoutPoster, onLoad, onError) {
7550
+ var mediaObject = $slide.find('.lg-object').first();
7512
7551
 
7513
- if (dummyImageLoaded) {
7514
- this.LGel.trigger(lGEvents.slideItemLoad, {
7515
- index: index,
7516
- delay: delay || 0,
7517
- isFirstSlide: isFirstSlide
7552
+ if (lg_utils.isImageLoaded(mediaObject.get()) || isHTML5VideoWithoutPoster) {
7553
+ onLoad();
7554
+ } else {
7555
+ mediaObject.on('load.lg error.lg', function () {
7556
+ onLoad && onLoad();
7557
+ });
7558
+ mediaObject.on('error.lg', function () {
7559
+ onError && onError();
7518
7560
  });
7519
7561
  }
7562
+ }
7563
+ /**
7564
+ *
7565
+ * @param $el Current slide item
7566
+ * @param index
7567
+ * @param delay Delay is 0 except first time
7568
+ * @param speed Speed is same as delay, except it is 0 if gallery is opened via hash plugin
7569
+ * @param isFirstSlide
7570
+ */
7571
+
7572
+ }, {
7573
+ key: "onLgObjectLoad",
7574
+ value: function onLgObjectLoad(currentSlide, index, delay, speed, isFirstSlide, isHTML5VideoWithoutPoster) {
7575
+ var _this7 = this;
7520
7576
 
7521
- $el.find('.lg-object').first().on('load.lg', function () {
7522
- _this7.handleLgObjectLoad($el, index, delay, speed, dummyImageLoaded, isFirstSlide);
7577
+ this.onSlideObjectLoad(currentSlide, isHTML5VideoWithoutPoster, function () {
7578
+ _this7.triggerSlideItemLoad(currentSlide, index, delay, speed, isFirstSlide);
7579
+ }, function () {
7580
+ currentSlide.addClass('lg-complete lg-complete_');
7581
+ currentSlide.html('<span class="lg-error-msg">Oops... Failed to load content...</span>');
7523
7582
  });
7524
- setTimeout(function () {
7525
- $el.find('.lg-object').first().on('error.lg', function () {
7526
- $el.addClass('lg-complete lg-complete_');
7527
- $el.html('<span class="lg-error-msg">Oops... Failed to load content...</span>');
7528
- });
7529
- }, speed);
7530
7583
  }
7531
7584
  }, {
7532
- key: "handleLgObjectLoad",
7533
- value: function handleLgObjectLoad($el, index, delay, speed, dummyImageLoaded, isFirstSlide) {
7585
+ key: "triggerSlideItemLoad",
7586
+ value: function triggerSlideItemLoad($currentSlide, index, delay, speed, isFirstSlide) {
7534
7587
  var _this8 = this;
7535
7588
 
7589
+ var currentGalleryItem = this.galleryItems[index]; // Adding delay for video slides without poster for better performance and user experience
7590
+ // Videos should start playing once once the gallery is completely loaded
7591
+
7592
+ var _speed = isFirstSlide && this.getSlideType(currentGalleryItem) === 'video' && !currentGalleryItem.poster ? speed : 0;
7593
+
7536
7594
  setTimeout(function () {
7537
- $el.addClass('lg-complete lg-complete_');
7595
+ $currentSlide.addClass('lg-complete lg-complete_');
7538
7596
 
7539
- if (!dummyImageLoaded) {
7540
- _this8.LGel.trigger(lGEvents.slideItemLoad, {
7541
- index: index,
7542
- delay: delay || 0,
7543
- isFirstSlide: isFirstSlide
7544
- });
7545
- }
7546
- }, speed);
7597
+ _this8.LGel.trigger(lGEvents.slideItemLoad, {
7598
+ index: index,
7599
+ delay: delay || 0,
7600
+ isFirstSlide: isFirstSlide
7601
+ });
7602
+ }, _speed);
7547
7603
  }
7548
- /**
7549
- * @desc Check the given src is video
7550
- * @param {String} src
7551
- * @return {Object} video type
7552
- * Ex:{ youtube : ["//www.youtube.com/watch?v=c0asJgSyxcY", "c0asJgSyxcY"] }
7553
- *
7554
- * @todo - this information can be moved to dynamicEl to avoid frequent calls
7555
- */
7556
-
7557
7604
  }, {
7558
- key: "isVideo",
7559
- value: function isVideo(src, index) {
7560
- if (!src) {
7561
- if (this.galleryItems[index].video) {
7562
- return {
7563
- html5: true
7564
- };
7565
- } else {
7566
- console.error('lightGallery :- data-src is not provided on slide item ' + (index + 1) + '. Please make sure the selector property is properly configured. More info - https://www.lightgalleryjs.com/demos/html-markup/');
7567
- return;
7568
- }
7569
- }
7570
-
7571
- var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)([\&|?][\S]*)*/i);
7572
- var vimeo = src.match(/\/\/(?:www\.)?(?:player\.)?vimeo.com\/(?:video\/)?([0-9a-z\-_]+)/i);
7573
- var wistia = src.match(/https?:\/\/(.+)?(wistia\.com|wi\.st)\/(medias|embed)\/([0-9a-z\-_]+)(.*)/);
7574
-
7575
- if (youtube) {
7576
- return {
7577
- youtube: youtube
7578
- };
7579
- } else if (vimeo) {
7580
- return {
7581
- vimeo: vimeo
7582
- };
7583
- } else if (wistia) {
7584
- return {
7585
- wistia: wistia
7586
- };
7587
- }
7605
+ key: "isFirstSlideWithZoomAnimation",
7606
+ value: function isFirstSlideWithZoomAnimation() {
7607
+ return !!(!this.lGalleryOn && this.zoomFromOrigin && this.currentImageSize);
7588
7608
  } // Add video slideInfo
7589
7609
 
7590
7610
  }, {
@@ -7593,7 +7613,11 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7593
7613
  var _this9 = this;
7594
7614
 
7595
7615
  items.forEach(function (element, index) {
7596
- element.__slideVideoInfo = _this9.isVideo(element.src, index);
7616
+ element.__slideVideoInfo = lg_utils.isVideo(element.src, !!element.video, index);
7617
+
7618
+ if (element.__slideVideoInfo && _this9.settings.loadYouTubePoster && !element.poster && element.__slideVideoInfo.youtube) {
7619
+ element.poster = "//img.youtube.com/vi/".concat(element.__slideVideoInfo.youtube[1], "/maxresdefault.jpg");
7620
+ }
7597
7621
  });
7598
7622
  }
7599
7623
  /**
@@ -7644,12 +7668,12 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7644
7668
  var _this$mediaContainerP3 = this.mediaContainerPosition,
7645
7669
  top = _this$mediaContainerP3.top,
7646
7670
  bottom = _this$mediaContainerP3.bottom;
7647
- var videoSize = lg_utils.getSize(this.items[index], this.outer, top + bottom, false, videoInfo && this.settings.videoMaxSize);
7671
+ var videoSize = lg_utils.getSize(this.items[index], this.outer, top + bottom, videoInfo && this.settings.videoMaxSize);
7648
7672
  lgVideoStyle = this.getVideoContStyle(videoSize);
7649
7673
  }
7650
7674
 
7651
7675
  if (iframe) {
7652
- var markup = lg_utils.getIframeMarkup(this.settings.iframeWidth, this.settings.iframeHeight, src, currentGalleryItem.iframeTitle);
7676
+ var markup = lg_utils.getIframeMarkup(this.settings.iframeWidth, this.settings.iframeHeight, this.settings.iframeMaxWidth, this.settings.iframeMaxHeight, src, currentGalleryItem.iframeTitle);
7653
7677
  $currentSlide.prepend(markup);
7654
7678
  } else if (poster) {
7655
7679
  var dummyImg = '';
@@ -7680,8 +7704,7 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7680
7704
  index: index,
7681
7705
  src: src,
7682
7706
  html5Video: _html5Video,
7683
- hasPoster: !!poster,
7684
- isFirstSlide: isFirstSlide
7707
+ hasPoster: !!poster
7685
7708
  });
7686
7709
  }
7687
7710
 
@@ -7700,33 +7723,34 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7700
7723
 
7701
7724
  if (delay && !$LG(document.body).hasClass('lg-from-hash')) {
7702
7725
  _speed = delay;
7703
- } // Only for first slide
7726
+ } // Only for first slide and zoomFromOrigin is enabled
7704
7727
 
7705
7728
 
7706
- if (!this.lGalleryOn && this.zoomFromOrigin && this.currentImageSize) {
7729
+ if (this.isFirstSlideWithZoomAnimation()) {
7707
7730
  setTimeout(function () {
7708
7731
  $currentSlide.removeClass('lg-start-end-progress lg-start-progress').removeAttr('style');
7709
7732
  }, this.settings.startAnimationDuration + 100);
7710
7733
 
7711
7734
  if (!$currentSlide.hasClass('lg-loaded')) {
7712
7735
  setTimeout(function () {
7713
- $currentSlide.find('.lg-img-wrap').append(lg_utils.getImgMarkup(index, src, '', srcset, sizes, currentGalleryItem.sources));
7736
+ if (_this10.getSlideType(currentGalleryItem) === 'image') {
7737
+ $currentSlide.find('.lg-img-wrap').append(lg_utils.getImgMarkup(index, src, '', srcset, sizes, currentGalleryItem.sources));
7714
7738
 
7715
- if (srcset || sources) {
7716
- var _$img = $currentSlide.find('.lg-object');
7739
+ if (srcset || sources) {
7740
+ var _$img = $currentSlide.find('.lg-object');
7717
7741
 
7718
- _this10.initPictureFill(_$img);
7742
+ _this10.initPictureFill(_$img);
7743
+ }
7719
7744
  }
7720
7745
 
7721
- _this10.onLgObjectLoad($currentSlide, index, delay, _speed, true, true);
7746
+ if (_this10.getSlideType(currentGalleryItem) === 'image' || _this10.getSlideType(currentGalleryItem) === 'video' && poster) {
7747
+ _this10.onLgObjectLoad($currentSlide, index, delay, _speed, true, false); // load remaining slides once the slide is completely loaded
7722
7748
 
7723
- var mediaObject = $currentSlide.find('.lg-object').first();
7724
7749
 
7725
- if (lg_utils.isImageLoaded(mediaObject.get())) {
7726
- _this10.loadContentOnLoad(index, $currentSlide, _speed);
7727
- } else {
7728
- mediaObject.on('load.lg error.lg', function () {
7729
- _this10.loadContentOnLoad(index, $currentSlide, _speed);
7750
+ _this10.onSlideObjectLoad($currentSlide, !!(videoInfo && videoInfo.html5 && !poster), function () {
7751
+ _this10.loadContentOnFirstSlideLoad(index, $currentSlide, _speed);
7752
+ }, function () {
7753
+ _this10.loadContentOnFirstSlideLoad(index, $currentSlide, _speed);
7730
7754
  });
7731
7755
  }
7732
7756
  }, this.settings.startAnimationDuration + 100);
@@ -7735,10 +7759,9 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7735
7759
 
7736
7760
 
7737
7761
  $currentSlide.addClass('lg-loaded');
7738
- this.onLgObjectLoad($currentSlide, index, delay, _speed, false, isFirstSlide); // @todo check load state for html5 videos
7739
7762
 
7740
- if (videoInfo && videoInfo.html5 && !poster) {
7741
- $currentSlide.addClass('lg-complete lg-complete_');
7763
+ if (!this.isFirstSlideWithZoomAnimation() || this.getSlideType(currentGalleryItem) === 'video' && !poster) {
7764
+ this.onLgObjectLoad($currentSlide, index, delay, _speed, isFirstSlide, !!(videoInfo && videoInfo.html5 && !poster));
7742
7765
  } // When gallery is opened once content is loaded (second time) need to add lg-complete class for css styling
7743
7766
 
7744
7767
 
@@ -7762,9 +7785,17 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7762
7785
  }
7763
7786
  }
7764
7787
  }
7788
+ /**
7789
+ * @desc Remove dummy image content and load next slides
7790
+ * Called only for the first time if zoomFromOrigin animation is enabled
7791
+ * @param index
7792
+ * @param $currentSlide
7793
+ * @param speed
7794
+ */
7795
+
7765
7796
  }, {
7766
- key: "loadContentOnLoad",
7767
- value: function loadContentOnLoad(index, $currentSlide, speed) {
7797
+ key: "loadContentOnFirstSlideLoad",
7798
+ value: function loadContentOnFirstSlideLoad(index, $currentSlide, speed) {
7768
7799
  var _this11 = this;
7769
7800
 
7770
7801
  setTimeout(function () {
@@ -7968,7 +7999,7 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7968
7999
  var _this$mediaContainerP4 = this.mediaContainerPosition,
7969
8000
  top = _this$mediaContainerP4.top,
7970
8001
  bottom = _this$mediaContainerP4.bottom;
7971
- var videoSize = lg_utils.getSize(this.items[index], this.outer, top + bottom, false, videoInfo && this.settings.videoMaxSize);
8002
+ var videoSize = lg_utils.getSize(this.items[index], this.outer, top + bottom, videoInfo && this.settings.videoMaxSize);
7972
8003
  this.resizeVideoSlide(index, videoSize);
7973
8004
  }
7974
8005
 
@@ -8027,18 +8058,17 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8027
8058
 
8028
8059
  if (!this.lGalleryOn) {
8029
8060
  this.loadContent(index, true);
8030
- }
8061
+ } else {
8062
+ setTimeout(function () {
8063
+ _this15.loadContent(index, true); // Add title if this.settings.appendSubHtmlTo === lg-sub-html
8031
8064
 
8032
- setTimeout(function () {
8033
- if (_this15.lGalleryOn) {
8034
- _this15.loadContent(index, true);
8035
- } // Add title if this.settings.appendSubHtmlTo === lg-sub-html
8036
8065
 
8066
+ if (_this15.settings.appendSubHtmlTo !== '.lg-item') {
8067
+ _this15.addHtml(index);
8068
+ }
8069
+ }, this.settings.speed + 50 + (fromTouch ? 0 : this.settings.slideDelay));
8070
+ }
8037
8071
 
8038
- if (_this15.settings.appendSubHtmlTo !== '.lg-item') {
8039
- _this15.addHtml(index);
8040
- }
8041
- }, (this.lGalleryOn ? this.settings.speed + 50 : 50) + (fromTouch ? 0 : this.settings.slideDelay));
8042
8072
  setTimeout(function () {
8043
8073
  _this15.lgBusy = false;
8044
8074
  previousSlideItem.removeClass('lg-slide-progress');
@@ -8530,18 +8560,26 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8530
8560
  value: function mousewheel() {
8531
8561
  var _this24 = this;
8532
8562
 
8533
- this.outer.on('mousewheel.lg', function (e) {
8563
+ var lastCall = 0;
8564
+ this.outer.on('wheel.lg', function (e) {
8534
8565
  if (!e.deltaY || _this24.galleryItems.length < 2) {
8535
8566
  return;
8536
8567
  }
8537
8568
 
8569
+ e.preventDefault();
8570
+ var now = new Date().getTime();
8571
+
8572
+ if (now - lastCall < 1000) {
8573
+ return;
8574
+ }
8575
+
8576
+ lastCall = now;
8577
+
8538
8578
  if (e.deltaY > 0) {
8539
- _this24.goToPrevSlide();
8540
- } else {
8541
8579
  _this24.goToNextSlide();
8580
+ } else if (e.deltaY < 0) {
8581
+ _this24.goToPrevSlide();
8542
8582
  }
8543
-
8544
- e.preventDefault();
8545
8583
  });
8546
8584
  }
8547
8585
  }, {
@@ -8650,7 +8688,7 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8650
8688
  var _this$galleryItems$th = this.galleryItems[this.index],
8651
8689
  __slideVideoInfo = _this$galleryItems$th.__slideVideoInfo,
8652
8690
  poster = _this$galleryItems$th.poster;
8653
- var imageSize = lg_utils.getSize(currentItem, this.outer, top + bottom, __slideVideoInfo && !poster, __slideVideoInfo && poster && this.settings.videoMaxSize);
8691
+ var imageSize = lg_utils.getSize(currentItem, this.outer, top + bottom, __slideVideoInfo && poster && this.settings.videoMaxSize);
8654
8692
  transform = lg_utils.getTransform(currentItem, this.outer, top, bottom, imageSize);
8655
8693
  }
8656
8694