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
@@ -5814,9 +5814,6 @@ var es_array_concat = __webpack_require__("99af");
5814
5814
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.find.js
5815
5815
  var es_array_find = __webpack_require__("7db0");
5816
5816
 
5817
- // EXTERNAL MODULE: ./node_modules/core-js/modules/es.string.match.js
5818
- var es_string_match = __webpack_require__("466d");
5819
-
5820
5817
  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
5821
5818
  function arrayLikeToArray_arrayLikeToArray(arr, len) {
5822
5819
  if (len == null || len > arr.length) len = arr.length;
@@ -5904,6 +5901,9 @@ var es_array_map = __webpack_require__("d81d");
5904
5901
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.splice.js
5905
5902
  var es_array_splice = __webpack_require__("a434");
5906
5903
 
5904
+ // EXTERNAL MODULE: ./node_modules/core-js/modules/es.string.match.js
5905
+ var es_string_match = __webpack_require__("466d");
5906
+
5907
5907
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.promise.js
5908
5908
  var es_promise = __webpack_require__("e6cf");
5909
5909
 
@@ -5924,28 +5924,30 @@ var es_regexp_to_string = __webpack_require__("25f0");
5924
5924
 
5925
5925
 
5926
5926
 
5927
- (function () {
5928
- if (typeof window.CustomEvent === 'function') return false;
5927
+ function initLgPolyfills() {
5928
+ (function () {
5929
+ if (typeof window.CustomEvent === 'function') return false;
5929
5930
 
5930
- function CustomEvent(event, params) {
5931
- params = params || {
5932
- bubbles: false,
5933
- cancelable: false,
5934
- detail: null
5935
- };
5936
- var evt = document.createEvent('CustomEvent');
5937
- evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
5938
- return evt;
5939
- }
5931
+ function CustomEvent(event, params) {
5932
+ params = params || {
5933
+ bubbles: false,
5934
+ cancelable: false,
5935
+ detail: null
5936
+ };
5937
+ var evt = document.createEvent('CustomEvent');
5938
+ evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
5939
+ return evt;
5940
+ }
5940
5941
 
5941
- window.CustomEvent = CustomEvent;
5942
- })();
5942
+ window.CustomEvent = CustomEvent;
5943
+ })();
5943
5944
 
5944
- (function () {
5945
- if (!Element.prototype.matches) {
5946
- Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
5947
- }
5948
- })();
5945
+ (function () {
5946
+ if (!Element.prototype.matches) {
5947
+ Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
5948
+ }
5949
+ })();
5950
+ }
5949
5951
 
5950
5952
  var lgQuery_lgQuery = /*#__PURE__*/function () {
5951
5953
  function lgQuery(selector) {
@@ -6108,7 +6110,9 @@ var lgQuery_lgQuery = /*#__PURE__*/function () {
6108
6110
  this._each(function (el) {
6109
6111
  // IE doesn't support multiple arguments
6110
6112
  classNames.split(' ').forEach(function (className) {
6111
- el.classList.add(className);
6113
+ if (className) {
6114
+ el.classList.add(className);
6115
+ }
6112
6116
  });
6113
6117
  });
6114
6118
 
@@ -6120,7 +6124,9 @@ var lgQuery_lgQuery = /*#__PURE__*/function () {
6120
6124
  this._each(function (el) {
6121
6125
  // IE doesn't support multiple arguments
6122
6126
  classNames.split(' ').forEach(function (className) {
6123
- el.classList.remove(className);
6127
+ if (className) {
6128
+ el.classList.remove(className);
6129
+ }
6124
6130
  });
6125
6131
  });
6126
6132
 
@@ -6382,6 +6388,7 @@ var lgQuery_lgQuery = /*#__PURE__*/function () {
6382
6388
  }();
6383
6389
  lgQuery_lgQuery.eventListeners = {};
6384
6390
  function $LG(selector) {
6391
+ initLgPolyfills();
6385
6392
  return new lgQuery_lgQuery(selector);
6386
6393
  }
6387
6394
  // CONCATENATED MODULE: ../src/lg-utils.ts
@@ -6398,6 +6405,7 @@ function $LG(selector) {
6398
6405
 
6399
6406
 
6400
6407
 
6408
+
6401
6409
  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
6402
6410
 
6403
6411
  function convertToData(attr) {
@@ -6417,15 +6425,13 @@ var utils = {
6417
6425
  /**
6418
6426
  * get possible width and height from the lgSize attribute. Used for ZoomFromOrigin option
6419
6427
  */
6420
- // @todo improive this
6421
6428
  getSize: function getSize(el, container) {
6422
6429
  var spacing = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
6423
- var isDisabled = arguments.length > 3 ? arguments[3] : undefined;
6424
- var defaultLgSize = arguments.length > 4 ? arguments[4] : undefined;
6430
+ var defaultLgSize = arguments.length > 3 ? arguments[3] : undefined;
6425
6431
  var LGel = $LG(el);
6426
6432
  var lgSize = LGel.attr('data-lg-size') || defaultLgSize;
6427
6433
 
6428
- if (!lgSize || isDisabled) {
6434
+ if (!lgSize) {
6429
6435
  return;
6430
6436
  }
6431
6437
 
@@ -6494,9 +6500,9 @@ var utils = {
6494
6500
  var transform = 'translate3d(' + (x *= -1) + 'px, ' + (y *= -1) + 'px, 0) scale3d(' + scX + ', ' + scY + ', 1)';
6495
6501
  return transform;
6496
6502
  },
6497
- getIframeMarkup: function getIframeMarkup(iframeWidth, iframeHeight, src, iframeTitle) {
6503
+ getIframeMarkup: function getIframeMarkup(iframeWidth, iframeHeight, iframeMaxWidth, iframeMaxHeight, src, iframeTitle) {
6498
6504
  var title = iframeTitle ? 'title="' + iframeTitle + '"' : '';
6499
- 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>");
6505
+ 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>");
6500
6506
  },
6501
6507
  getImgMarkup: function getImgMarkup(index, src, altAttr, srcset, sizes, sources) {
6502
6508
  var srcsetAttr = srcset ? "srcset=\"".concat(srcset, "\"") : '';
@@ -6627,6 +6633,45 @@ var utils = {
6627
6633
  },
6628
6634
  isMobile: function isMobile() {
6629
6635
  return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
6636
+ },
6637
+
6638
+ /**
6639
+ * @desc Check the given src is video
6640
+ * @param {String} src
6641
+ * @return {Object} video type
6642
+ * Ex:{ youtube : ["//www.youtube.com/watch?v=c0asJgSyxcY", "c0asJgSyxcY"] }
6643
+ *
6644
+ * @todo - this information can be moved to dynamicEl to avoid frequent calls
6645
+ */
6646
+ isVideo: function isVideo(src, isHTML5VIdeo, index) {
6647
+ if (!src) {
6648
+ if (isHTML5VIdeo) {
6649
+ return {
6650
+ html5: true
6651
+ };
6652
+ } else {
6653
+ 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/');
6654
+ return;
6655
+ }
6656
+ }
6657
+
6658
+ var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)([\&|?][\S]*)*/i);
6659
+ var vimeo = src.match(/\/\/(?:www\.)?(?:player\.)?vimeo.com\/(?:video\/)?([0-9a-z\-_]+)(.*)?/i);
6660
+ var wistia = src.match(/https?:\/\/(.+)?(wistia\.com|wi\.st)\/(medias|embed)\/([0-9a-z\-_]+)(.*)/);
6661
+
6662
+ if (youtube) {
6663
+ return {
6664
+ youtube: youtube
6665
+ };
6666
+ } else if (vimeo) {
6667
+ return {
6668
+ vimeo: vimeo
6669
+ };
6670
+ } else if (wistia) {
6671
+ return {
6672
+ wistia: wistia
6673
+ };
6674
+ }
6630
6675
  }
6631
6676
  };
6632
6677
  /* harmony default export */ var lg_utils = (utils);
@@ -6641,7 +6686,7 @@ var lightGalleryCoreSettings = {
6641
6686
  addClass: '',
6642
6687
  startClass: 'lg-start-zoom',
6643
6688
  backdropDuration: 300,
6644
- container: document.body,
6689
+ container: '',
6645
6690
  startAnimationDuration: 400,
6646
6691
  zoomFromOrigin: true,
6647
6692
  hideBarsDelay: 0,
@@ -6650,6 +6695,7 @@ var lightGalleryCoreSettings = {
6650
6695
  supportLegacyBrowser: true,
6651
6696
  allowMediaOverlap: false,
6652
6697
  videoMaxSize: '1280-720',
6698
+ loadYouTubePoster: true,
6653
6699
  defaultCaptionHeight: 0,
6654
6700
  ariaLabelledby: '',
6655
6701
  ariaDescribedby: '',
@@ -6670,7 +6716,6 @@ var lightGalleryCoreSettings = {
6670
6716
  subHtmlSelectorRelative: false,
6671
6717
  preload: 2,
6672
6718
  numberOfSlideItemsInDom: 10,
6673
- showAfterLoad: true,
6674
6719
  selector: '',
6675
6720
  selectWithin: '',
6676
6721
  nextHtml: '',
@@ -6678,6 +6723,8 @@ var lightGalleryCoreSettings = {
6678
6723
  index: 0,
6679
6724
  iframeWidth: '100%',
6680
6725
  iframeHeight: '100%',
6726
+ iframeMaxWidth: '100%',
6727
+ iframeMaxHeight: '100%',
6681
6728
  download: true,
6682
6729
  counter: true,
6683
6730
  appendCounterTo: '.lg-toolbar',
@@ -6739,7 +6786,6 @@ var lGEvents = {
6739
6786
 
6740
6787
 
6741
6788
 
6742
-
6743
6789
  // @ref - https://stackoverflow.com/questions/3971841/how-to-resize-images-proportionally-keeping-the-aspect-ratio
6744
6790
  // @ref - https://2ality.com/2017/04/setting-up-multi-platform-packages.html
6745
6791
  // Unique id for each gallery
@@ -6989,10 +7035,6 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
6989
7035
  outerClassNames += 'lg-grab ';
6990
7036
  }
6991
7037
 
6992
- if (this.settings.showAfterLoad) {
6993
- outerClassNames += 'lg-show-after-load';
6994
- }
6995
-
6996
7038
  this.outer.addClass(outerClassNames);
6997
7039
  this.$inner.css('transition-timing-function', this.settings.easing);
6998
7040
  this.$inner.css('transition-duration', this.settings.speed + 'ms');
@@ -7015,13 +7057,12 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7015
7057
  value: function refreshOnResize() {
7016
7058
  if (this.lgOpened) {
7017
7059
  var currentGalleryItem = this.galleryItems[this.index];
7018
- var __slideVideoInfo = currentGalleryItem.__slideVideoInfo,
7019
- poster = currentGalleryItem.poster;
7060
+ var __slideVideoInfo = currentGalleryItem.__slideVideoInfo;
7020
7061
  this.mediaContainerPosition = this.getMediaContainerPosition();
7021
7062
  var _this$mediaContainerP = this.mediaContainerPosition,
7022
7063
  top = _this$mediaContainerP.top,
7023
7064
  bottom = _this$mediaContainerP.bottom;
7024
- this.currentImageSize = lg_utils.getSize(this.items[this.index], this.outer, top + bottom, __slideVideoInfo && !poster, __slideVideoInfo && this.settings.videoMaxSize);
7065
+ this.currentImageSize = lg_utils.getSize(this.items[this.index], this.outer, top + bottom, __slideVideoInfo && this.settings.videoMaxSize);
7025
7066
 
7026
7067
  if (__slideVideoInfo) {
7027
7068
  this.resizeVideoSlide(this.index, this.currentImageSize);
@@ -7214,12 +7255,10 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7214
7255
  this.setMediaContainerPosition(top, bottom);
7215
7256
  }
7216
7257
 
7217
- var _this$galleryItems$in = this.galleryItems[index],
7218
- __slideVideoInfo = _this$galleryItems$in.__slideVideoInfo,
7219
- poster = _this$galleryItems$in.poster;
7258
+ var __slideVideoInfo = this.galleryItems[index].__slideVideoInfo;
7220
7259
 
7221
7260
  if (this.zoomFromOrigin && element) {
7222
- this.currentImageSize = lg_utils.getSize(element, this.outer, top + bottom, __slideVideoInfo && !poster, __slideVideoInfo && this.settings.videoMaxSize);
7261
+ this.currentImageSize = lg_utils.getSize(element, this.outer, top + bottom, __slideVideoInfo && this.settings.videoMaxSize);
7223
7262
  transform = lg_utils.getTransform(element, this.outer, top, bottom, this.currentImageSize);
7224
7263
  }
7225
7264
 
@@ -7505,7 +7544,7 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7505
7544
  var imgContent = '';
7506
7545
  var altAttr = alt ? 'alt="' + alt + '"' : '';
7507
7546
 
7508
- if (!this.lGalleryOn && this.zoomFromOrigin && this.currentImageSize) {
7547
+ if (this.isFirstSlideWithZoomAnimation()) {
7509
7548
  imgContent = this.getDummyImageContent($currentSlide, index, altAttr);
7510
7549
  } else {
7511
7550
  imgContent = lg_utils.getImgMarkup(index, src, altAttr, srcset, sizes, sources);
@@ -7515,85 +7554,66 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7515
7554
  $currentSlide.prepend(imgMarkup);
7516
7555
  }
7517
7556
  }, {
7518
- key: "onLgObjectLoad",
7519
- value: function onLgObjectLoad($el, index, delay, speed, dummyImageLoaded, isFirstSlide) {
7520
- var _this7 = this;
7557
+ key: "onSlideObjectLoad",
7558
+ value: function onSlideObjectLoad($slide, isHTML5VideoWithoutPoster, onLoad, onError) {
7559
+ var mediaObject = $slide.find('.lg-object').first();
7521
7560
 
7522
- if (dummyImageLoaded) {
7523
- this.LGel.trigger(lGEvents.slideItemLoad, {
7524
- index: index,
7525
- delay: delay || 0,
7526
- isFirstSlide: isFirstSlide
7561
+ if (lg_utils.isImageLoaded(mediaObject.get()) || isHTML5VideoWithoutPoster) {
7562
+ onLoad();
7563
+ } else {
7564
+ mediaObject.on('load.lg error.lg', function () {
7565
+ onLoad && onLoad();
7566
+ });
7567
+ mediaObject.on('error.lg', function () {
7568
+ onError && onError();
7527
7569
  });
7528
7570
  }
7571
+ }
7572
+ /**
7573
+ *
7574
+ * @param $el Current slide item
7575
+ * @param index
7576
+ * @param delay Delay is 0 except first time
7577
+ * @param speed Speed is same as delay, except it is 0 if gallery is opened via hash plugin
7578
+ * @param isFirstSlide
7579
+ */
7580
+
7581
+ }, {
7582
+ key: "onLgObjectLoad",
7583
+ value: function onLgObjectLoad(currentSlide, index, delay, speed, isFirstSlide, isHTML5VideoWithoutPoster) {
7584
+ var _this7 = this;
7529
7585
 
7530
- $el.find('.lg-object').first().on('load.lg', function () {
7531
- _this7.handleLgObjectLoad($el, index, delay, speed, dummyImageLoaded, isFirstSlide);
7586
+ this.onSlideObjectLoad(currentSlide, isHTML5VideoWithoutPoster, function () {
7587
+ _this7.triggerSlideItemLoad(currentSlide, index, delay, speed, isFirstSlide);
7588
+ }, function () {
7589
+ currentSlide.addClass('lg-complete lg-complete_');
7590
+ currentSlide.html('<span class="lg-error-msg">Oops... Failed to load content...</span>');
7532
7591
  });
7533
- setTimeout(function () {
7534
- $el.find('.lg-object').first().on('error.lg', function () {
7535
- $el.addClass('lg-complete lg-complete_');
7536
- $el.html('<span class="lg-error-msg">Oops... Failed to load content...</span>');
7537
- });
7538
- }, speed);
7539
7592
  }
7540
7593
  }, {
7541
- key: "handleLgObjectLoad",
7542
- value: function handleLgObjectLoad($el, index, delay, speed, dummyImageLoaded, isFirstSlide) {
7594
+ key: "triggerSlideItemLoad",
7595
+ value: function triggerSlideItemLoad($currentSlide, index, delay, speed, isFirstSlide) {
7543
7596
  var _this8 = this;
7544
7597
 
7598
+ var currentGalleryItem = this.galleryItems[index]; // Adding delay for video slides without poster for better performance and user experience
7599
+ // Videos should start playing once once the gallery is completely loaded
7600
+
7601
+ var _speed = isFirstSlide && this.getSlideType(currentGalleryItem) === 'video' && !currentGalleryItem.poster ? speed : 0;
7602
+
7545
7603
  setTimeout(function () {
7546
- $el.addClass('lg-complete lg-complete_');
7604
+ $currentSlide.addClass('lg-complete lg-complete_');
7547
7605
 
7548
- if (!dummyImageLoaded) {
7549
- _this8.LGel.trigger(lGEvents.slideItemLoad, {
7550
- index: index,
7551
- delay: delay || 0,
7552
- isFirstSlide: isFirstSlide
7553
- });
7554
- }
7555
- }, speed);
7606
+ _this8.LGel.trigger(lGEvents.slideItemLoad, {
7607
+ index: index,
7608
+ delay: delay || 0,
7609
+ isFirstSlide: isFirstSlide
7610
+ });
7611
+ }, _speed);
7556
7612
  }
7557
- /**
7558
- * @desc Check the given src is video
7559
- * @param {String} src
7560
- * @return {Object} video type
7561
- * Ex:{ youtube : ["//www.youtube.com/watch?v=c0asJgSyxcY", "c0asJgSyxcY"] }
7562
- *
7563
- * @todo - this information can be moved to dynamicEl to avoid frequent calls
7564
- */
7565
-
7566
7613
  }, {
7567
- key: "isVideo",
7568
- value: function isVideo(src, index) {
7569
- if (!src) {
7570
- if (this.galleryItems[index].video) {
7571
- return {
7572
- html5: true
7573
- };
7574
- } else {
7575
- 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/');
7576
- return;
7577
- }
7578
- }
7579
-
7580
- var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)([\&|?][\S]*)*/i);
7581
- var vimeo = src.match(/\/\/(?:www\.)?(?:player\.)?vimeo.com\/(?:video\/)?([0-9a-z\-_]+)/i);
7582
- var wistia = src.match(/https?:\/\/(.+)?(wistia\.com|wi\.st)\/(medias|embed)\/([0-9a-z\-_]+)(.*)/);
7583
-
7584
- if (youtube) {
7585
- return {
7586
- youtube: youtube
7587
- };
7588
- } else if (vimeo) {
7589
- return {
7590
- vimeo: vimeo
7591
- };
7592
- } else if (wistia) {
7593
- return {
7594
- wistia: wistia
7595
- };
7596
- }
7614
+ key: "isFirstSlideWithZoomAnimation",
7615
+ value: function isFirstSlideWithZoomAnimation() {
7616
+ return !!(!this.lGalleryOn && this.zoomFromOrigin && this.currentImageSize);
7597
7617
  } // Add video slideInfo
7598
7618
 
7599
7619
  }, {
@@ -7602,7 +7622,11 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7602
7622
  var _this9 = this;
7603
7623
 
7604
7624
  items.forEach(function (element, index) {
7605
- element.__slideVideoInfo = _this9.isVideo(element.src, index);
7625
+ element.__slideVideoInfo = lg_utils.isVideo(element.src, !!element.video, index);
7626
+
7627
+ if (element.__slideVideoInfo && _this9.settings.loadYouTubePoster && !element.poster && element.__slideVideoInfo.youtube) {
7628
+ element.poster = "//img.youtube.com/vi/".concat(element.__slideVideoInfo.youtube[1], "/maxresdefault.jpg");
7629
+ }
7606
7630
  });
7607
7631
  }
7608
7632
  /**
@@ -7653,12 +7677,12 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7653
7677
  var _this$mediaContainerP3 = this.mediaContainerPosition,
7654
7678
  top = _this$mediaContainerP3.top,
7655
7679
  bottom = _this$mediaContainerP3.bottom;
7656
- var videoSize = lg_utils.getSize(this.items[index], this.outer, top + bottom, false, videoInfo && this.settings.videoMaxSize);
7680
+ var videoSize = lg_utils.getSize(this.items[index], this.outer, top + bottom, videoInfo && this.settings.videoMaxSize);
7657
7681
  lgVideoStyle = this.getVideoContStyle(videoSize);
7658
7682
  }
7659
7683
 
7660
7684
  if (iframe) {
7661
- var markup = lg_utils.getIframeMarkup(this.settings.iframeWidth, this.settings.iframeHeight, src, currentGalleryItem.iframeTitle);
7685
+ var markup = lg_utils.getIframeMarkup(this.settings.iframeWidth, this.settings.iframeHeight, this.settings.iframeMaxWidth, this.settings.iframeMaxHeight, src, currentGalleryItem.iframeTitle);
7662
7686
  $currentSlide.prepend(markup);
7663
7687
  } else if (poster) {
7664
7688
  var dummyImg = '';
@@ -7689,8 +7713,7 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7689
7713
  index: index,
7690
7714
  src: src,
7691
7715
  html5Video: _html5Video,
7692
- hasPoster: !!poster,
7693
- isFirstSlide: isFirstSlide
7716
+ hasPoster: !!poster
7694
7717
  });
7695
7718
  }
7696
7719
 
@@ -7709,33 +7732,34 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7709
7732
 
7710
7733
  if (delay && !$LG(document.body).hasClass('lg-from-hash')) {
7711
7734
  _speed = delay;
7712
- } // Only for first slide
7735
+ } // Only for first slide and zoomFromOrigin is enabled
7713
7736
 
7714
7737
 
7715
- if (!this.lGalleryOn && this.zoomFromOrigin && this.currentImageSize) {
7738
+ if (this.isFirstSlideWithZoomAnimation()) {
7716
7739
  setTimeout(function () {
7717
7740
  $currentSlide.removeClass('lg-start-end-progress lg-start-progress').removeAttr('style');
7718
7741
  }, this.settings.startAnimationDuration + 100);
7719
7742
 
7720
7743
  if (!$currentSlide.hasClass('lg-loaded')) {
7721
7744
  setTimeout(function () {
7722
- $currentSlide.find('.lg-img-wrap').append(lg_utils.getImgMarkup(index, src, '', srcset, sizes, currentGalleryItem.sources));
7745
+ if (_this10.getSlideType(currentGalleryItem) === 'image') {
7746
+ $currentSlide.find('.lg-img-wrap').append(lg_utils.getImgMarkup(index, src, '', srcset, sizes, currentGalleryItem.sources));
7723
7747
 
7724
- if (srcset || sources) {
7725
- var _$img = $currentSlide.find('.lg-object');
7748
+ if (srcset || sources) {
7749
+ var _$img = $currentSlide.find('.lg-object');
7726
7750
 
7727
- _this10.initPictureFill(_$img);
7751
+ _this10.initPictureFill(_$img);
7752
+ }
7728
7753
  }
7729
7754
 
7730
- _this10.onLgObjectLoad($currentSlide, index, delay, _speed, true, true);
7755
+ if (_this10.getSlideType(currentGalleryItem) === 'image' || _this10.getSlideType(currentGalleryItem) === 'video' && poster) {
7756
+ _this10.onLgObjectLoad($currentSlide, index, delay, _speed, true, false); // load remaining slides once the slide is completely loaded
7731
7757
 
7732
- var mediaObject = $currentSlide.find('.lg-object').first();
7733
7758
 
7734
- if (lg_utils.isImageLoaded(mediaObject.get())) {
7735
- _this10.loadContentOnLoad(index, $currentSlide, _speed);
7736
- } else {
7737
- mediaObject.on('load.lg error.lg', function () {
7738
- _this10.loadContentOnLoad(index, $currentSlide, _speed);
7759
+ _this10.onSlideObjectLoad($currentSlide, !!(videoInfo && videoInfo.html5 && !poster), function () {
7760
+ _this10.loadContentOnFirstSlideLoad(index, $currentSlide, _speed);
7761
+ }, function () {
7762
+ _this10.loadContentOnFirstSlideLoad(index, $currentSlide, _speed);
7739
7763
  });
7740
7764
  }
7741
7765
  }, this.settings.startAnimationDuration + 100);
@@ -7744,10 +7768,9 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7744
7768
 
7745
7769
 
7746
7770
  $currentSlide.addClass('lg-loaded');
7747
- this.onLgObjectLoad($currentSlide, index, delay, _speed, false, isFirstSlide); // @todo check load state for html5 videos
7748
7771
 
7749
- if (videoInfo && videoInfo.html5 && !poster) {
7750
- $currentSlide.addClass('lg-complete lg-complete_');
7772
+ if (!this.isFirstSlideWithZoomAnimation() || this.getSlideType(currentGalleryItem) === 'video' && !poster) {
7773
+ this.onLgObjectLoad($currentSlide, index, delay, _speed, isFirstSlide, !!(videoInfo && videoInfo.html5 && !poster));
7751
7774
  } // When gallery is opened once content is loaded (second time) need to add lg-complete class for css styling
7752
7775
 
7753
7776
 
@@ -7771,9 +7794,17 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7771
7794
  }
7772
7795
  }
7773
7796
  }
7797
+ /**
7798
+ * @desc Remove dummy image content and load next slides
7799
+ * Called only for the first time if zoomFromOrigin animation is enabled
7800
+ * @param index
7801
+ * @param $currentSlide
7802
+ * @param speed
7803
+ */
7804
+
7774
7805
  }, {
7775
- key: "loadContentOnLoad",
7776
- value: function loadContentOnLoad(index, $currentSlide, speed) {
7806
+ key: "loadContentOnFirstSlideLoad",
7807
+ value: function loadContentOnFirstSlideLoad(index, $currentSlide, speed) {
7777
7808
  var _this11 = this;
7778
7809
 
7779
7810
  setTimeout(function () {
@@ -7977,7 +8008,7 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7977
8008
  var _this$mediaContainerP4 = this.mediaContainerPosition,
7978
8009
  top = _this$mediaContainerP4.top,
7979
8010
  bottom = _this$mediaContainerP4.bottom;
7980
- var videoSize = lg_utils.getSize(this.items[index], this.outer, top + bottom, false, videoInfo && this.settings.videoMaxSize);
8011
+ var videoSize = lg_utils.getSize(this.items[index], this.outer, top + bottom, videoInfo && this.settings.videoMaxSize);
7981
8012
  this.resizeVideoSlide(index, videoSize);
7982
8013
  }
7983
8014
 
@@ -8036,18 +8067,17 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8036
8067
 
8037
8068
  if (!this.lGalleryOn) {
8038
8069
  this.loadContent(index, true);
8039
- }
8070
+ } else {
8071
+ setTimeout(function () {
8072
+ _this15.loadContent(index, true); // Add title if this.settings.appendSubHtmlTo === lg-sub-html
8040
8073
 
8041
- setTimeout(function () {
8042
- if (_this15.lGalleryOn) {
8043
- _this15.loadContent(index, true);
8044
- } // Add title if this.settings.appendSubHtmlTo === lg-sub-html
8045
8074
 
8075
+ if (_this15.settings.appendSubHtmlTo !== '.lg-item') {
8076
+ _this15.addHtml(index);
8077
+ }
8078
+ }, this.settings.speed + 50 + (fromTouch ? 0 : this.settings.slideDelay));
8079
+ }
8046
8080
 
8047
- if (_this15.settings.appendSubHtmlTo !== '.lg-item') {
8048
- _this15.addHtml(index);
8049
- }
8050
- }, (this.lGalleryOn ? this.settings.speed + 50 : 50) + (fromTouch ? 0 : this.settings.slideDelay));
8051
8081
  setTimeout(function () {
8052
8082
  _this15.lgBusy = false;
8053
8083
  previousSlideItem.removeClass('lg-slide-progress');
@@ -8539,18 +8569,26 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8539
8569
  value: function mousewheel() {
8540
8570
  var _this24 = this;
8541
8571
 
8542
- this.outer.on('mousewheel.lg', function (e) {
8572
+ var lastCall = 0;
8573
+ this.outer.on('wheel.lg', function (e) {
8543
8574
  if (!e.deltaY || _this24.galleryItems.length < 2) {
8544
8575
  return;
8545
8576
  }
8546
8577
 
8578
+ e.preventDefault();
8579
+ var now = new Date().getTime();
8580
+
8581
+ if (now - lastCall < 1000) {
8582
+ return;
8583
+ }
8584
+
8585
+ lastCall = now;
8586
+
8547
8587
  if (e.deltaY > 0) {
8548
- _this24.goToPrevSlide();
8549
- } else {
8550
8588
  _this24.goToNextSlide();
8589
+ } else if (e.deltaY < 0) {
8590
+ _this24.goToPrevSlide();
8551
8591
  }
8552
-
8553
- e.preventDefault();
8554
8592
  });
8555
8593
  }
8556
8594
  }, {
@@ -8659,7 +8697,7 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8659
8697
  var _this$galleryItems$th = this.galleryItems[this.index],
8660
8698
  __slideVideoInfo = _this$galleryItems$th.__slideVideoInfo,
8661
8699
  poster = _this$galleryItems$th.poster;
8662
- var imageSize = lg_utils.getSize(currentItem, this.outer, top + bottom, __slideVideoInfo && !poster, __slideVideoInfo && poster && this.settings.videoMaxSize);
8700
+ var imageSize = lg_utils.getSize(currentItem, this.outer, top + bottom, __slideVideoInfo && poster && this.settings.videoMaxSize);
8663
8701
  transform = lg_utils.getTransform(currentItem, this.outer, top, bottom, imageSize);
8664
8702
  }
8665
8703