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
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * lightgallery | 2.3.0-beta.1 | August 31st 2021
2
+ * lightgallery | 2.3.0 | October 28th 2021
3
3
  * http://www.lightgalleryjs.com/
4
4
  * Copyright (c) 2020 Sachin Neravath;
5
5
  * @license GPLv3
@@ -45,24 +45,30 @@
45
45
  return r;
46
46
  }
47
47
 
48
- (function () {
49
- if (typeof window.CustomEvent === 'function')
50
- return false;
51
- function CustomEvent(event, params) {
52
- params = params || { bubbles: false, cancelable: false, detail: null };
53
- var evt = document.createEvent('CustomEvent');
54
- evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
55
- return evt;
56
- }
57
- window.CustomEvent = CustomEvent;
58
- })();
59
- (function () {
60
- if (!Element.prototype.matches) {
61
- Element.prototype.matches =
62
- Element.prototype.msMatchesSelector ||
63
- Element.prototype.webkitMatchesSelector;
64
- }
65
- })();
48
+ function initLgPolyfills() {
49
+ (function () {
50
+ if (typeof window.CustomEvent === 'function')
51
+ return false;
52
+ function CustomEvent(event, params) {
53
+ params = params || {
54
+ bubbles: false,
55
+ cancelable: false,
56
+ detail: null,
57
+ };
58
+ var evt = document.createEvent('CustomEvent');
59
+ evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
60
+ return evt;
61
+ }
62
+ window.CustomEvent = CustomEvent;
63
+ })();
64
+ (function () {
65
+ if (!Element.prototype.matches) {
66
+ Element.prototype.matches =
67
+ Element.prototype.msMatchesSelector ||
68
+ Element.prototype.webkitMatchesSelector;
69
+ }
70
+ })();
71
+ }
66
72
  var lgQuery = /** @class */ (function () {
67
73
  function lgQuery(selector) {
68
74
  this.cssVenderPrefixes = [
@@ -195,7 +201,9 @@
195
201
  this._each(function (el) {
196
202
  // IE doesn't support multiple arguments
197
203
  classNames.split(' ').forEach(function (className) {
198
- el.classList.add(className);
204
+ if (className) {
205
+ el.classList.add(className);
206
+ }
199
207
  });
200
208
  });
201
209
  return this;
@@ -204,7 +212,9 @@
204
212
  this._each(function (el) {
205
213
  // IE doesn't support multiple arguments
206
214
  classNames.split(' ').forEach(function (className) {
207
- el.classList.remove(className);
215
+ if (className) {
216
+ el.classList.remove(className);
217
+ }
208
218
  });
209
219
  });
210
220
  return this;
@@ -404,6 +414,7 @@
404
414
  return lgQuery;
405
415
  }());
406
416
  function $LG(selector) {
417
+ initLgPolyfills();
407
418
  return new lgQuery(selector);
408
419
  }
409
420
 
@@ -448,12 +459,11 @@
448
459
  /**
449
460
  * get possible width and height from the lgSize attribute. Used for ZoomFromOrigin option
450
461
  */
451
- // @todo improive this
452
- getSize: function (el, container, spacing, isDisabled, defaultLgSize) {
462
+ getSize: function (el, container, spacing, defaultLgSize) {
453
463
  if (spacing === void 0) { spacing = 0; }
454
464
  var LGel = $LG(el);
455
465
  var lgSize = LGel.attr('data-lg-size') || defaultLgSize;
456
- if (!lgSize || isDisabled) {
466
+ if (!lgSize) {
457
467
  return;
458
468
  }
459
469
  var isResponsiveSizes = lgSize.split(',');
@@ -528,9 +538,9 @@
528
538
  ', 1)';
529
539
  return transform;
530
540
  },
531
- getIframeMarkup: function (iframeWidth, iframeHeight, src, iframeTitle) {
541
+ getIframeMarkup: function (iframeWidth, iframeHeight, iframeMaxWidth, iframeMaxHeight, src, iframeTitle) {
532
542
  var title = iframeTitle ? 'title="' + iframeTitle + '"' : '';
533
- return "<div class=\"lg-video-cont lg-has-iframe\" style=\"width:" + iframeWidth + "; height: " + iframeHeight + "\">\n <iframe class=\"lg-object\" frameborder=\"0\" " + title + " src=\"" + src + "\" allowfullscreen=\"true\"></iframe>\n </div>";
543
+ return "<div class=\"lg-video-cont lg-has-iframe\" style=\"width:" + iframeWidth + "; max-width:" + iframeMaxWidth + "; height: " + iframeHeight + "; max-height:" + iframeMaxHeight + "\">\n <iframe class=\"lg-object\" frameborder=\"0\" " + title + " src=\"" + src + "\" allowfullscreen=\"true\"></iframe>\n </div>";
534
544
  },
535
545
  getImgMarkup: function (index, src, altAttr, srcset, sizes, sources) {
536
546
  var srcsetAttr = srcset ? "srcset=\"" + srcset + "\"" : '';
@@ -647,6 +657,47 @@
647
657
  isMobile: function () {
648
658
  return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
649
659
  },
660
+ /**
661
+ * @desc Check the given src is video
662
+ * @param {String} src
663
+ * @return {Object} video type
664
+ * Ex:{ youtube : ["//www.youtube.com/watch?v=c0asJgSyxcY", "c0asJgSyxcY"] }
665
+ *
666
+ * @todo - this information can be moved to dynamicEl to avoid frequent calls
667
+ */
668
+ isVideo: function (src, isHTML5VIdeo, index) {
669
+ if (!src) {
670
+ if (isHTML5VIdeo) {
671
+ return {
672
+ html5: true,
673
+ };
674
+ }
675
+ else {
676
+ console.error('lightGallery :- data-src is not provided on slide item ' +
677
+ (index + 1) +
678
+ '. Please make sure the selector property is properly configured. More info - https://www.lightgalleryjs.com/demos/html-markup/');
679
+ return;
680
+ }
681
+ }
682
+ var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)([\&|?][\S]*)*/i);
683
+ var vimeo = src.match(/\/\/(?:www\.)?(?:player\.)?vimeo.com\/(?:video\/)?([0-9a-z\-_]+)(.*)?/i);
684
+ var wistia = src.match(/https?:\/\/(.+)?(wistia\.com|wi\.st)\/(medias|embed)\/([0-9a-z\-_]+)(.*)/);
685
+ if (youtube) {
686
+ return {
687
+ youtube: youtube,
688
+ };
689
+ }
690
+ else if (vimeo) {
691
+ return {
692
+ vimeo: vimeo,
693
+ };
694
+ }
695
+ else if (wistia) {
696
+ return {
697
+ wistia: wistia,
698
+ };
699
+ }
700
+ },
650
701
  };
651
702
 
652
703
  var lightGalleryCoreSettings = {
@@ -659,7 +710,7 @@
659
710
  addClass: '',
660
711
  startClass: 'lg-start-zoom',
661
712
  backdropDuration: 300,
662
- container: document.body,
713
+ container: '',
663
714
  startAnimationDuration: 400,
664
715
  zoomFromOrigin: true,
665
716
  hideBarsDelay: 0,
@@ -668,6 +719,7 @@
668
719
  supportLegacyBrowser: true,
669
720
  allowMediaOverlap: false,
670
721
  videoMaxSize: '1280-720',
722
+ loadYouTubePoster: true,
671
723
  defaultCaptionHeight: 0,
672
724
  ariaLabelledby: '',
673
725
  ariaDescribedby: '',
@@ -688,7 +740,6 @@
688
740
  subHtmlSelectorRelative: false,
689
741
  preload: 2,
690
742
  numberOfSlideItemsInDom: 10,
691
- showAfterLoad: true,
692
743
  selector: '',
693
744
  selectWithin: '',
694
745
  nextHtml: '',
@@ -696,6 +747,8 @@
696
747
  index: 0,
697
748
  iframeWidth: '100%',
698
749
  iframeHeight: '100%',
750
+ iframeMaxWidth: '100%',
751
+ iframeMaxHeight: '100%',
699
752
  download: true,
700
753
  counter: true,
701
754
  appendCounterTo: '.lg-toolbar',
@@ -962,9 +1015,6 @@
962
1015
  if (this.settings.enableDrag) {
963
1016
  outerClassNames += 'lg-grab ';
964
1017
  }
965
- if (this.settings.showAfterLoad) {
966
- outerClassNames += 'lg-show-after-load';
967
- }
968
1018
  this.outer.addClass(outerClassNames);
969
1019
  this.$inner.css('transition-timing-function', this.settings.easing);
970
1020
  this.$inner.css('transition-duration', this.settings.speed + 'ms');
@@ -983,10 +1033,10 @@
983
1033
  LightGallery.prototype.refreshOnResize = function () {
984
1034
  if (this.lgOpened) {
985
1035
  var currentGalleryItem = this.galleryItems[this.index];
986
- var __slideVideoInfo = currentGalleryItem.__slideVideoInfo, poster = currentGalleryItem.poster;
1036
+ var __slideVideoInfo = currentGalleryItem.__slideVideoInfo;
987
1037
  this.mediaContainerPosition = this.getMediaContainerPosition();
988
1038
  var _a = this.mediaContainerPosition, top_1 = _a.top, bottom = _a.bottom;
989
- this.currentImageSize = utils.getSize(this.items[this.index], this.outer, top_1 + bottom, __slideVideoInfo && !poster, __slideVideoInfo && this.settings.videoMaxSize);
1039
+ this.currentImageSize = utils.getSize(this.items[this.index], this.outer, top_1 + bottom, __slideVideoInfo && this.settings.videoMaxSize);
990
1040
  if (__slideVideoInfo) {
991
1041
  this.resizeVideoSlide(this.index, this.currentImageSize);
992
1042
  }
@@ -1165,9 +1215,9 @@
1165
1215
  if (!this.settings.allowMediaOverlap) {
1166
1216
  this.setMediaContainerPosition(top, bottom);
1167
1217
  }
1168
- var _b = this.galleryItems[index], __slideVideoInfo = _b.__slideVideoInfo, poster = _b.poster;
1218
+ var __slideVideoInfo = this.galleryItems[index].__slideVideoInfo;
1169
1219
  if (this.zoomFromOrigin && element) {
1170
- this.currentImageSize = utils.getSize(element, this.outer, top + bottom, __slideVideoInfo && !poster, __slideVideoInfo && this.settings.videoMaxSize);
1220
+ this.currentImageSize = utils.getSize(element, this.outer, top + bottom, __slideVideoInfo && this.settings.videoMaxSize);
1171
1221
  transform = utils.getTransform(element, this.outer, top, bottom, this.currentImageSize);
1172
1222
  }
1173
1223
  if (!this.zoomFromOrigin || !transform) {
@@ -1421,7 +1471,7 @@
1421
1471
  // displayed on top of actual image
1422
1472
  var imgContent = '';
1423
1473
  var altAttr = alt ? 'alt="' + alt + '"' : '';
1424
- if (!this.lGalleryOn && this.zoomFromOrigin && this.currentImageSize) {
1474
+ if (this.isFirstSlideWithZoomAnimation()) {
1425
1475
  imgContent = this.getDummyImageContent($currentSlide, index, altAttr);
1426
1476
  }
1427
1477
  else {
@@ -1430,88 +1480,73 @@
1430
1480
  var imgMarkup = "<picture class=\"lg-img-wrap\"> " + imgContent + "</picture>";
1431
1481
  $currentSlide.prepend(imgMarkup);
1432
1482
  };
1433
- LightGallery.prototype.onLgObjectLoad = function ($el, index, delay, speed, dummyImageLoaded, isFirstSlide) {
1434
- var _this = this;
1435
- if (dummyImageLoaded) {
1436
- this.LGel.trigger(lGEvents.slideItemLoad, {
1437
- index: index,
1438
- delay: delay || 0,
1439
- isFirstSlide: isFirstSlide,
1483
+ LightGallery.prototype.onSlideObjectLoad = function ($slide, isHTML5VideoWithoutPoster, onLoad, onError) {
1484
+ var mediaObject = $slide.find('.lg-object').first();
1485
+ if (utils.isImageLoaded(mediaObject.get()) ||
1486
+ isHTML5VideoWithoutPoster) {
1487
+ onLoad();
1488
+ }
1489
+ else {
1490
+ mediaObject.on('load.lg error.lg', function () {
1491
+ onLoad && onLoad();
1492
+ });
1493
+ mediaObject.on('error.lg', function () {
1494
+ onError && onError();
1440
1495
  });
1441
1496
  }
1442
- $el.find('.lg-object')
1443
- .first()
1444
- .on('load.lg', function () {
1445
- _this.handleLgObjectLoad($el, index, delay, speed, dummyImageLoaded, isFirstSlide);
1497
+ };
1498
+ /**
1499
+ *
1500
+ * @param $el Current slide item
1501
+ * @param index
1502
+ * @param delay Delay is 0 except first time
1503
+ * @param speed Speed is same as delay, except it is 0 if gallery is opened via hash plugin
1504
+ * @param isFirstSlide
1505
+ */
1506
+ LightGallery.prototype.onLgObjectLoad = function (currentSlide, index, delay, speed, isFirstSlide, isHTML5VideoWithoutPoster) {
1507
+ var _this = this;
1508
+ this.onSlideObjectLoad(currentSlide, isHTML5VideoWithoutPoster, function () {
1509
+ _this.triggerSlideItemLoad(currentSlide, index, delay, speed, isFirstSlide);
1510
+ }, function () {
1511
+ currentSlide.addClass('lg-complete lg-complete_');
1512
+ currentSlide.html('<span class="lg-error-msg">Oops... Failed to load content...</span>');
1446
1513
  });
1447
- setTimeout(function () {
1448
- $el.find('.lg-object')
1449
- .first()
1450
- .on('error.lg', function () {
1451
- $el.addClass('lg-complete lg-complete_');
1452
- $el.html('<span class="lg-error-msg">Oops... Failed to load content...</span>');
1453
- });
1454
- }, speed);
1455
1514
  };
1456
- LightGallery.prototype.handleLgObjectLoad = function ($el, index, delay, speed, dummyImageLoaded, isFirstSlide) {
1515
+ LightGallery.prototype.triggerSlideItemLoad = function ($currentSlide, index, delay, speed, isFirstSlide) {
1457
1516
  var _this = this;
1517
+ var currentGalleryItem = this.galleryItems[index];
1518
+ // Adding delay for video slides without poster for better performance and user experience
1519
+ // Videos should start playing once once the gallery is completely loaded
1520
+ var _speed = isFirstSlide &&
1521
+ this.getSlideType(currentGalleryItem) === 'video' &&
1522
+ !currentGalleryItem.poster
1523
+ ? speed
1524
+ : 0;
1458
1525
  setTimeout(function () {
1459
- $el.addClass('lg-complete lg-complete_');
1460
- if (!dummyImageLoaded) {
1461
- _this.LGel.trigger(lGEvents.slideItemLoad, {
1462
- index: index,
1463
- delay: delay || 0,
1464
- isFirstSlide: isFirstSlide,
1465
- });
1466
- }
1467
- }, speed);
1526
+ $currentSlide.addClass('lg-complete lg-complete_');
1527
+ _this.LGel.trigger(lGEvents.slideItemLoad, {
1528
+ index: index,
1529
+ delay: delay || 0,
1530
+ isFirstSlide: isFirstSlide,
1531
+ });
1532
+ }, _speed);
1468
1533
  };
1469
- /**
1470
- * @desc Check the given src is video
1471
- * @param {String} src
1472
- * @return {Object} video type
1473
- * Ex:{ youtube : ["//www.youtube.com/watch?v=c0asJgSyxcY", "c0asJgSyxcY"] }
1474
- *
1475
- * @todo - this information can be moved to dynamicEl to avoid frequent calls
1476
- */
1477
- LightGallery.prototype.isVideo = function (src, index) {
1478
- if (!src) {
1479
- if (this.galleryItems[index].video) {
1480
- return {
1481
- html5: true,
1482
- };
1483
- }
1484
- else {
1485
- console.error('lightGallery :- data-src is not provided on slide item ' +
1486
- (index + 1) +
1487
- '. Please make sure the selector property is properly configured. More info - https://www.lightgalleryjs.com/demos/html-markup/');
1488
- return;
1489
- }
1490
- }
1491
- var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)([\&|?][\S]*)*/i);
1492
- var vimeo = src.match(/\/\/(?:www\.)?(?:player\.)?vimeo.com\/(?:video\/)?([0-9a-z\-_]+)/i);
1493
- var wistia = src.match(/https?:\/\/(.+)?(wistia\.com|wi\.st)\/(medias|embed)\/([0-9a-z\-_]+)(.*)/);
1494
- if (youtube) {
1495
- return {
1496
- youtube: youtube,
1497
- };
1498
- }
1499
- else if (vimeo) {
1500
- return {
1501
- vimeo: vimeo,
1502
- };
1503
- }
1504
- else if (wistia) {
1505
- return {
1506
- wistia: wistia,
1507
- };
1508
- }
1534
+ LightGallery.prototype.isFirstSlideWithZoomAnimation = function () {
1535
+ return !!(!this.lGalleryOn &&
1536
+ this.zoomFromOrigin &&
1537
+ this.currentImageSize);
1509
1538
  };
1510
1539
  // Add video slideInfo
1511
1540
  LightGallery.prototype.addSlideVideoInfo = function (items) {
1512
1541
  var _this = this;
1513
1542
  items.forEach(function (element, index) {
1514
- element.__slideVideoInfo = _this.isVideo(element.src, index);
1543
+ element.__slideVideoInfo = utils.isVideo(element.src, !!element.video, index);
1544
+ if (element.__slideVideoInfo &&
1545
+ _this.settings.loadYouTubePoster &&
1546
+ !element.poster &&
1547
+ element.__slideVideoInfo.youtube) {
1548
+ element.poster = "//img.youtube.com/vi/" + element.__slideVideoInfo.youtube[1] + "/maxresdefault.jpg";
1549
+ }
1515
1550
  });
1516
1551
  };
1517
1552
  /**
@@ -1549,11 +1584,11 @@
1549
1584
  if (!$currentSlide.hasClass('lg-loaded')) {
1550
1585
  if (videoInfo) {
1551
1586
  var _a = this.mediaContainerPosition, top_2 = _a.top, bottom = _a.bottom;
1552
- var videoSize = utils.getSize(this.items[index], this.outer, top_2 + bottom, false, videoInfo && this.settings.videoMaxSize);
1587
+ var videoSize = utils.getSize(this.items[index], this.outer, top_2 + bottom, videoInfo && this.settings.videoMaxSize);
1553
1588
  lgVideoStyle = this.getVideoContStyle(videoSize);
1554
1589
  }
1555
1590
  if (iframe) {
1556
- var markup = utils.getIframeMarkup(this.settings.iframeWidth, this.settings.iframeHeight, src, currentGalleryItem.iframeTitle);
1591
+ var markup = utils.getIframeMarkup(this.settings.iframeWidth, this.settings.iframeHeight, this.settings.iframeMaxWidth, this.settings.iframeMaxHeight, src, currentGalleryItem.iframeTitle);
1557
1592
  $currentSlide.prepend(markup);
1558
1593
  }
1559
1594
  else if (poster) {
@@ -1584,7 +1619,6 @@
1584
1619
  src: src,
1585
1620
  html5Video: _html5Video,
1586
1621
  hasPoster: !!poster,
1587
- isFirstSlide: isFirstSlide,
1588
1622
  });
1589
1623
  }
1590
1624
  this.LGel.trigger(lGEvents.afterAppendSlide, { index: index });
@@ -1600,8 +1634,8 @@
1600
1634
  if (delay && !$LG(document.body).hasClass('lg-from-hash')) {
1601
1635
  _speed = delay;
1602
1636
  }
1603
- // Only for first slide
1604
- if (!this.lGalleryOn && this.zoomFromOrigin && this.currentImageSize) {
1637
+ // Only for first slide and zoomFromOrigin is enabled
1638
+ if (this.isFirstSlideWithZoomAnimation()) {
1605
1639
  setTimeout(function () {
1606
1640
  $currentSlide
1607
1641
  .removeClass('lg-start-end-progress lg-start-progress')
@@ -1609,23 +1643,24 @@
1609
1643
  }, this.settings.startAnimationDuration + 100);
1610
1644
  if (!$currentSlide.hasClass('lg-loaded')) {
1611
1645
  setTimeout(function () {
1612
- $currentSlide
1613
- .find('.lg-img-wrap')
1614
- .append(utils.getImgMarkup(index, src, '', srcset, sizes, currentGalleryItem.sources));
1615
- if (srcset || sources) {
1616
- var $img = $currentSlide.find('.lg-object');
1617
- _this.initPictureFill($img);
1618
- }
1619
- _this.onLgObjectLoad($currentSlide, index, delay, _speed, true, true);
1620
- var mediaObject = $currentSlide
1621
- .find('.lg-object')
1622
- .first();
1623
- if (utils.isImageLoaded(mediaObject.get())) {
1624
- _this.loadContentOnLoad(index, $currentSlide, _speed);
1646
+ if (_this.getSlideType(currentGalleryItem) === 'image') {
1647
+ $currentSlide
1648
+ .find('.lg-img-wrap')
1649
+ .append(utils.getImgMarkup(index, src, '', srcset, sizes, currentGalleryItem.sources));
1650
+ if (srcset || sources) {
1651
+ var $img = $currentSlide.find('.lg-object');
1652
+ _this.initPictureFill($img);
1653
+ }
1625
1654
  }
1626
- else {
1627
- mediaObject.on('load.lg error.lg', function () {
1628
- _this.loadContentOnLoad(index, $currentSlide, _speed);
1655
+ if (_this.getSlideType(currentGalleryItem) === 'image' ||
1656
+ (_this.getSlideType(currentGalleryItem) === 'video' &&
1657
+ poster)) {
1658
+ _this.onLgObjectLoad($currentSlide, index, delay, _speed, true, false);
1659
+ // load remaining slides once the slide is completely loaded
1660
+ _this.onSlideObjectLoad($currentSlide, !!(videoInfo && videoInfo.html5 && !poster), function () {
1661
+ _this.loadContentOnFirstSlideLoad(index, $currentSlide, _speed);
1662
+ }, function () {
1663
+ _this.loadContentOnFirstSlideLoad(index, $currentSlide, _speed);
1629
1664
  });
1630
1665
  }
1631
1666
  }, this.settings.startAnimationDuration + 100);
@@ -1633,10 +1668,9 @@
1633
1668
  }
1634
1669
  // SLide content has been added to dom
1635
1670
  $currentSlide.addClass('lg-loaded');
1636
- this.onLgObjectLoad($currentSlide, index, delay, _speed, false, isFirstSlide);
1637
- // @todo check load state for html5 videos
1638
- if (videoInfo && videoInfo.html5 && !poster) {
1639
- $currentSlide.addClass('lg-complete lg-complete_');
1671
+ if (!this.isFirstSlideWithZoomAnimation() ||
1672
+ (this.getSlideType(currentGalleryItem) === 'video' && !poster)) {
1673
+ this.onLgObjectLoad($currentSlide, index, delay, _speed, isFirstSlide, !!(videoInfo && videoInfo.html5 && !poster));
1640
1674
  }
1641
1675
  // When gallery is opened once content is loaded (second time) need to add lg-complete class for css styling
1642
1676
  if ((!this.zoomFromOrigin || !this.currentImageSize) &&
@@ -1663,7 +1697,14 @@
1663
1697
  }
1664
1698
  }
1665
1699
  };
1666
- LightGallery.prototype.loadContentOnLoad = function (index, $currentSlide, speed) {
1700
+ /**
1701
+ * @desc Remove dummy image content and load next slides
1702
+ * Called only for the first time if zoomFromOrigin animation is enabled
1703
+ * @param index
1704
+ * @param $currentSlide
1705
+ * @param speed
1706
+ */
1707
+ LightGallery.prototype.loadContentOnFirstSlideLoad = function (index, $currentSlide, speed) {
1667
1708
  var _this = this;
1668
1709
  setTimeout(function () {
1669
1710
  $currentSlide.find('.lg-dummy-img').remove();
@@ -1834,7 +1875,7 @@
1834
1875
  this.setDownloadValue(index);
1835
1876
  if (videoInfo) {
1836
1877
  var _a = this.mediaContainerPosition, top_3 = _a.top, bottom = _a.bottom;
1837
- var videoSize = utils.getSize(this.items[index], this.outer, top_3 + bottom, false, videoInfo && this.settings.videoMaxSize);
1878
+ var videoSize = utils.getSize(this.items[index], this.outer, top_3 + bottom, videoInfo && this.settings.videoMaxSize);
1838
1879
  this.resizeVideoSlide(index, videoSize);
1839
1880
  }
1840
1881
  this.LGel.trigger(lGEvents.beforeSlide, {
@@ -1894,15 +1935,15 @@
1894
1935
  if (!this.lGalleryOn) {
1895
1936
  this.loadContent(index, true);
1896
1937
  }
1897
- setTimeout(function () {
1898
- if (_this.lGalleryOn) {
1938
+ else {
1939
+ setTimeout(function () {
1899
1940
  _this.loadContent(index, true);
1900
- }
1901
- // Add title if this.settings.appendSubHtmlTo === lg-sub-html
1902
- if (_this.settings.appendSubHtmlTo !== '.lg-item') {
1903
- _this.addHtml(index);
1904
- }
1905
- }, (this.lGalleryOn ? this.settings.speed + 50 : 50) + (fromTouch ? 0 : this.settings.slideDelay));
1941
+ // Add title if this.settings.appendSubHtmlTo === lg-sub-html
1942
+ if (_this.settings.appendSubHtmlTo !== '.lg-item') {
1943
+ _this.addHtml(index);
1944
+ }
1945
+ }, this.settings.speed + 50 + (fromTouch ? 0 : this.settings.slideDelay));
1946
+ }
1906
1947
  setTimeout(function () {
1907
1948
  _this.lgBusy = false;
1908
1949
  previousSlideItem_1.removeClass('lg-slide-progress');
@@ -2341,17 +2382,23 @@
2341
2382
  };
2342
2383
  LightGallery.prototype.mousewheel = function () {
2343
2384
  var _this = this;
2344
- this.outer.on('mousewheel.lg', function (e) {
2385
+ var lastCall = 0;
2386
+ this.outer.on('wheel.lg', function (e) {
2345
2387
  if (!e.deltaY || _this.galleryItems.length < 2) {
2346
2388
  return;
2347
2389
  }
2348
- if (e.deltaY > 0) {
2349
- _this.goToPrevSlide();
2390
+ e.preventDefault();
2391
+ var now = new Date().getTime();
2392
+ if (now - lastCall < 1000) {
2393
+ return;
2350
2394
  }
2351
- else {
2395
+ lastCall = now;
2396
+ if (e.deltaY > 0) {
2352
2397
  _this.goToNextSlide();
2353
2398
  }
2354
- e.preventDefault();
2399
+ else if (e.deltaY < 0) {
2400
+ _this.goToPrevSlide();
2401
+ }
2355
2402
  });
2356
2403
  };
2357
2404
  LightGallery.prototype.isSlideElement = function (target) {
@@ -2441,7 +2488,7 @@
2441
2488
  if (this.zoomFromOrigin && currentItem) {
2442
2489
  var _a = this.mediaContainerPosition, top_4 = _a.top, bottom = _a.bottom;
2443
2490
  var _b = this.galleryItems[this.index], __slideVideoInfo = _b.__slideVideoInfo, poster = _b.poster;
2444
- var imageSize = utils.getSize(currentItem, this.outer, top_4 + bottom, __slideVideoInfo && !poster, __slideVideoInfo && poster && this.settings.videoMaxSize);
2491
+ var imageSize = utils.getSize(currentItem, this.outer, top_4 + bottom, __slideVideoInfo && poster && this.settings.videoMaxSize);
2445
2492
  transform = utils.getTransform(currentItem, this.outer, top_4, bottom, imageSize);
2446
2493
  }
2447
2494
  if (this.zoomFromOrigin && transform) {