lightgallery 2.5.0-beta.3 → 2.5.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 (72) hide show
  1. package/css/lightgallery-bundle.css +4 -0
  2. package/css/lightgallery-bundle.min.css +1 -1
  3. package/css/lightgallery-core.css +4 -0
  4. package/css/lightgallery.css +4 -0
  5. package/lg-settings.d.ts +14 -1
  6. package/lib/lg-settings.js +2 -0
  7. package/lib/lg-settings.js.map +1 -1
  8. package/lib/lightgallery.js +34 -3
  9. package/lib/lightgallery.js.map +1 -1
  10. package/lib/plugins/video/lg-video-settings.js.map +1 -1
  11. package/lightgallery.d.ts +4 -0
  12. package/lightgallery.es5.js +37 -4
  13. package/lightgallery.es5.js.map +1 -1
  14. package/lightgallery.min.js +2 -2
  15. package/lightgallery.umd.js +37 -4
  16. package/lightgallery.umd.js.map +1 -1
  17. package/lit/lightgallery.esm.js +4 -4
  18. package/lit/lightgallery.umd.js +2 -2
  19. package/package.json +1 -1
  20. package/plugins/autoplay/lg-autoplay.es5.js +1 -1
  21. package/plugins/autoplay/lg-autoplay.min.js +1 -1
  22. package/plugins/autoplay/lg-autoplay.umd.js +1 -1
  23. package/plugins/comment/lg-comment.es5.js +1 -1
  24. package/plugins/comment/lg-comment.min.js +1 -1
  25. package/plugins/comment/lg-comment.umd.js +1 -1
  26. package/plugins/fullscreen/lg-fullscreen.es5.js +1 -1
  27. package/plugins/fullscreen/lg-fullscreen.min.js +1 -1
  28. package/plugins/fullscreen/lg-fullscreen.umd.js +1 -1
  29. package/plugins/hash/lg-hash.es5.js +1 -1
  30. package/plugins/hash/lg-hash.min.js +1 -1
  31. package/plugins/hash/lg-hash.umd.js +1 -1
  32. package/plugins/mediumZoom/lg-medium-zoom.es5.js +1 -1
  33. package/plugins/mediumZoom/lg-medium-zoom.min.js +1 -1
  34. package/plugins/mediumZoom/lg-medium-zoom.umd.js +1 -1
  35. package/plugins/pager/lg-pager.es5.js +1 -1
  36. package/plugins/pager/lg-pager.min.js +1 -1
  37. package/plugins/pager/lg-pager.umd.js +1 -1
  38. package/plugins/relativeCaption/lg-relative-caption.es5.js +1 -1
  39. package/plugins/relativeCaption/lg-relative-caption.min.js +1 -1
  40. package/plugins/relativeCaption/lg-relative-caption.umd.js +1 -1
  41. package/plugins/rotate/lg-rotate.es5.js +1 -1
  42. package/plugins/rotate/lg-rotate.min.js +1 -1
  43. package/plugins/rotate/lg-rotate.umd.js +1 -1
  44. package/plugins/share/lg-share.es5.js +1 -1
  45. package/plugins/share/lg-share.min.js +1 -1
  46. package/plugins/share/lg-share.umd.js +1 -1
  47. package/plugins/thumbnail/lg-thumbnail.es5.js +1 -1
  48. package/plugins/thumbnail/lg-thumbnail.min.js +1 -1
  49. package/plugins/thumbnail/lg-thumbnail.umd.js +1 -1
  50. package/plugins/video/lg-video-settings.d.ts +1 -0
  51. package/plugins/video/lg-video.es5.js +1 -1
  52. package/plugins/video/lg-video.es5.js.map +1 -1
  53. package/plugins/video/lg-video.min.js +1 -1
  54. package/plugins/video/lg-video.umd.js +1 -1
  55. package/plugins/video/lg-video.umd.js.map +1 -1
  56. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.es5.js +1 -1
  57. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.min.js +1 -1
  58. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.umd.js +1 -1
  59. package/plugins/zoom/lg-zoom.es5.js +1 -1
  60. package/plugins/zoom/lg-zoom.min.js +1 -1
  61. package/plugins/zoom/lg-zoom.umd.js +1 -1
  62. package/react/Lightgallery.es5.js +37 -4
  63. package/react/Lightgallery.es5.js.map +1 -1
  64. package/react/Lightgallery.umd.js +37 -4
  65. package/react/Lightgallery.umd.js.map +1 -1
  66. package/scss/lightgallery-core.scss +3 -0
  67. package/vue/LightGalleryVue.common.js +48 -5
  68. package/vue/LightGalleryVue.common.js.map +1 -1
  69. package/vue/LightGalleryVue.umd.js +48 -5
  70. package/vue/LightGalleryVue.umd.js.map +1 -1
  71. package/vue/LightGalleryVue.umd.min.js +2 -2
  72. package/vue/LightGalleryVue.umd.min.js.map +1 -1
@@ -32,7 +32,7 @@
32
32
  }
33
33
 
34
34
  /*!
35
- * lightgallery | 2.5.0-beta.3 | April 23rd 2022
35
+ * lightgallery | 2.5.0 | June 13th 2022
36
36
  * http://www.lightgalleryjs.com/
37
37
  * Copyright (c) 2020 Sachin Neravath;
38
38
  * @license GPLv3
@@ -129,6 +129,8 @@
129
129
  defaultCaptionHeight: 0,
130
130
  ariaLabelledby: '',
131
131
  ariaDescribedby: '',
132
+ resetScrollPosition: true,
133
+ hideScrollbar: false,
132
134
  closable: true,
133
135
  swipeToClose: true,
134
136
  closeOnTap: true,
@@ -865,6 +867,7 @@
865
867
  this.currentItemsInDom = [];
866
868
  // Scroll top value before lightGallery is opened
867
869
  this.prevScrollTop = 0;
870
+ this.bodyPaddingRight = 0;
868
871
  this.isDummyImageRemoved = false;
869
872
  this.dragOrSwipeEnabled = false;
870
873
  this.mediaContainerPosition = {
@@ -1212,6 +1215,27 @@
1212
1215
  return this.settings.dynamicEl || [];
1213
1216
  }
1214
1217
  };
1218
+ LightGallery.prototype.shouldHideScrollbar = function () {
1219
+ return (this.settings.hideScrollbar &&
1220
+ document.body === this.settings.container);
1221
+ };
1222
+ LightGallery.prototype.hideScrollbar = function () {
1223
+ if (!this.shouldHideScrollbar()) {
1224
+ return;
1225
+ }
1226
+ this.bodyPaddingRight = parseFloat($LG('body').style().paddingRight);
1227
+ var bodyRect = document.documentElement.getBoundingClientRect();
1228
+ var scrollbarWidth = window.innerWidth - bodyRect.width;
1229
+ $LG(document.body).css('padding-right', scrollbarWidth + this.bodyPaddingRight + 'px');
1230
+ $LG(document.body).addClass('lg-overlay-open');
1231
+ };
1232
+ LightGallery.prototype.resetScrollBar = function () {
1233
+ if (!this.shouldHideScrollbar()) {
1234
+ return;
1235
+ }
1236
+ $LG(document.body).css('padding-right', this.bodyPaddingRight + 'px');
1237
+ $LG(document.body).removeClass('lg-overlay-open');
1238
+ };
1215
1239
  /**
1216
1240
  * Open lightGallery.
1217
1241
  * Open gallery with specific slide by passing index of the slide as parameter.
@@ -1248,6 +1272,7 @@
1248
1272
  return;
1249
1273
  this.lgOpened = true;
1250
1274
  this.outer.removeClass('lg-hide-items');
1275
+ this.hideScrollbar();
1251
1276
  // Add display block, but still has opacity 0
1252
1277
  this.$container.addClass('lg-show');
1253
1278
  var itemsToBeInsertedToDom = this.getItemsToBeInsertedToDom(index, index);
@@ -1699,9 +1724,11 @@
1699
1724
  if (!$currentSlide.hasClass('lg-loaded')) {
1700
1725
  setTimeout(function () {
1701
1726
  if (_this.getSlideType(currentGalleryItem) === 'image') {
1727
+ var alt = currentGalleryItem.alt;
1728
+ var altAttr = alt ? 'alt="' + alt + '"' : '';
1702
1729
  $currentSlide
1703
1730
  .find('.lg-img-wrap')
1704
- .append(utils.getImgMarkup(index, src, '', srcset, sizes, currentGalleryItem.sources));
1731
+ .append(utils.getImgMarkup(index, src, altAttr, srcset, sizes, currentGalleryItem.sources));
1705
1732
  if (srcset || sources) {
1706
1733
  var $img = $currentSlide.find('.lg-object');
1707
1734
  _this.initPictureFill($img);
@@ -2489,7 +2516,9 @@
2489
2516
  };
2490
2517
  LightGallery.prototype.trapFocus = function () {
2491
2518
  var _this = this;
2492
- this.$container.get().focus();
2519
+ this.$container.get().focus({
2520
+ preventScroll: true,
2521
+ });
2493
2522
  $LG(window).on("keydown.lg.global" + this.lgId, function (e) {
2494
2523
  if (!_this.lgOpened) {
2495
2524
  return;
@@ -2565,7 +2594,9 @@
2565
2594
  return 0;
2566
2595
  }
2567
2596
  this.LGel.trigger(lGEvents.beforeClose);
2568
- $LG(window).scrollTop(this.prevScrollTop);
2597
+ if (this.settings.resetScrollPosition && !this.settings.hideScrollbar) {
2598
+ $LG(window).scrollTop(this.prevScrollTop);
2599
+ }
2569
2600
  var currentItem = this.items[this.index];
2570
2601
  var transform;
2571
2602
  if (this.zoomFromOrigin && currentItem) {
@@ -2610,6 +2641,8 @@
2610
2641
  _this.outer.removeClass('lg-zoom-from-image');
2611
2642
  }
2612
2643
  _this.$container.removeClass('lg-show');
2644
+ // Reset scrollbar
2645
+ _this.resetScrollBar();
2613
2646
  // Need to remove inline opacity as it is used in the stylesheet as well
2614
2647
  _this.$backdrop
2615
2648
  .removeAttr('style')