lightgallery 2.5.0-beta.3 → 2.5.0-beta.4

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 (68) 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 +10 -0
  6. package/lib/lg-settings.js +2 -0
  7. package/lib/lg-settings.js.map +1 -1
  8. package/lib/lightgallery.js +31 -2
  9. package/lib/lightgallery.js.map +1 -1
  10. package/lightgallery.d.ts +4 -0
  11. package/lightgallery.es5.js +34 -3
  12. package/lightgallery.es5.js.map +1 -1
  13. package/lightgallery.min.js +2 -2
  14. package/lightgallery.umd.js +34 -3
  15. package/lightgallery.umd.js.map +1 -1
  16. package/lit/lightgallery.esm.js +4 -4
  17. package/lit/lightgallery.umd.js +2 -2
  18. package/package.json +1 -1
  19. package/plugins/autoplay/lg-autoplay.es5.js +1 -1
  20. package/plugins/autoplay/lg-autoplay.min.js +1 -1
  21. package/plugins/autoplay/lg-autoplay.umd.js +1 -1
  22. package/plugins/comment/lg-comment.es5.js +1 -1
  23. package/plugins/comment/lg-comment.min.js +1 -1
  24. package/plugins/comment/lg-comment.umd.js +1 -1
  25. package/plugins/fullscreen/lg-fullscreen.es5.js +1 -1
  26. package/plugins/fullscreen/lg-fullscreen.min.js +1 -1
  27. package/plugins/fullscreen/lg-fullscreen.umd.js +1 -1
  28. package/plugins/hash/lg-hash.es5.js +1 -1
  29. package/plugins/hash/lg-hash.min.js +1 -1
  30. package/plugins/hash/lg-hash.umd.js +1 -1
  31. package/plugins/mediumZoom/lg-medium-zoom.es5.js +1 -1
  32. package/plugins/mediumZoom/lg-medium-zoom.min.js +1 -1
  33. package/plugins/mediumZoom/lg-medium-zoom.umd.js +1 -1
  34. package/plugins/pager/lg-pager.es5.js +1 -1
  35. package/plugins/pager/lg-pager.min.js +1 -1
  36. package/plugins/pager/lg-pager.umd.js +1 -1
  37. package/plugins/relativeCaption/lg-relative-caption.es5.js +1 -1
  38. package/plugins/relativeCaption/lg-relative-caption.min.js +1 -1
  39. package/plugins/relativeCaption/lg-relative-caption.umd.js +1 -1
  40. package/plugins/rotate/lg-rotate.es5.js +1 -1
  41. package/plugins/rotate/lg-rotate.min.js +1 -1
  42. package/plugins/rotate/lg-rotate.umd.js +1 -1
  43. package/plugins/share/lg-share.es5.js +1 -1
  44. package/plugins/share/lg-share.min.js +1 -1
  45. package/plugins/share/lg-share.umd.js +1 -1
  46. package/plugins/thumbnail/lg-thumbnail.es5.js +1 -1
  47. package/plugins/thumbnail/lg-thumbnail.min.js +1 -1
  48. package/plugins/thumbnail/lg-thumbnail.umd.js +1 -1
  49. package/plugins/video/lg-video.es5.js +1 -1
  50. package/plugins/video/lg-video.min.js +1 -1
  51. package/plugins/video/lg-video.umd.js +1 -1
  52. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.es5.js +1 -1
  53. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.min.js +1 -1
  54. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.umd.js +1 -1
  55. package/plugins/zoom/lg-zoom.es5.js +1 -1
  56. package/plugins/zoom/lg-zoom.min.js +1 -1
  57. package/plugins/zoom/lg-zoom.umd.js +1 -1
  58. package/react/Lightgallery.es5.js +34 -3
  59. package/react/Lightgallery.es5.js.map +1 -1
  60. package/react/Lightgallery.umd.js +34 -3
  61. package/react/Lightgallery.umd.js.map +1 -1
  62. package/scss/lightgallery-core.scss +3 -0
  63. package/vue/LightGalleryVue.common.js +45 -4
  64. package/vue/LightGalleryVue.common.js.map +1 -1
  65. package/vue/LightGalleryVue.umd.js +45 -4
  66. package/vue/LightGalleryVue.umd.js.map +1 -1
  67. package/vue/LightGalleryVue.umd.min.js +2 -2
  68. package/vue/LightGalleryVue.umd.min.js.map +1 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * lightgallery | 2.5.0-beta.3 | April 23rd 2022
2
+ * lightgallery | 2.5.0-beta.4 | May 9th 2022
3
3
  * http://www.lightgalleryjs.com/
4
4
  * Copyright (c) 2020 Sachin Neravath;
5
5
  * @license GPLv3
@@ -96,6 +96,8 @@ var lightGalleryCoreSettings = {
96
96
  defaultCaptionHeight: 0,
97
97
  ariaLabelledby: '',
98
98
  ariaDescribedby: '',
99
+ resetScrollPosition: true,
100
+ hideScrollbar: false,
99
101
  closable: true,
100
102
  swipeToClose: true,
101
103
  closeOnTap: true,
@@ -832,6 +834,7 @@ var LightGallery = /** @class */ (function () {
832
834
  this.currentItemsInDom = [];
833
835
  // Scroll top value before lightGallery is opened
834
836
  this.prevScrollTop = 0;
837
+ this.bodyPaddingRight = 0;
835
838
  this.isDummyImageRemoved = false;
836
839
  this.dragOrSwipeEnabled = false;
837
840
  this.mediaContainerPosition = {
@@ -1179,6 +1182,27 @@ var LightGallery = /** @class */ (function () {
1179
1182
  return this.settings.dynamicEl || [];
1180
1183
  }
1181
1184
  };
1185
+ LightGallery.prototype.shouldHideScrollbar = function () {
1186
+ return (this.settings.hideScrollbar &&
1187
+ document.body === this.settings.container);
1188
+ };
1189
+ LightGallery.prototype.hideScrollbar = function () {
1190
+ if (!this.shouldHideScrollbar()) {
1191
+ return;
1192
+ }
1193
+ this.bodyPaddingRight = parseFloat($LG('body').style().paddingRight);
1194
+ var bodyRect = document.documentElement.getBoundingClientRect();
1195
+ var scrollbarWidth = window.innerWidth - bodyRect.width;
1196
+ $LG(document.body).css('padding-right', scrollbarWidth + this.bodyPaddingRight + 'px');
1197
+ $LG(document.body).addClass('lg-overlay-open');
1198
+ };
1199
+ LightGallery.prototype.resetScrollBar = function () {
1200
+ if (!this.shouldHideScrollbar()) {
1201
+ return;
1202
+ }
1203
+ $LG(document.body).css('padding-right', this.bodyPaddingRight + 'px');
1204
+ $LG(document.body).removeClass('lg-overlay-open');
1205
+ };
1182
1206
  /**
1183
1207
  * Open lightGallery.
1184
1208
  * Open gallery with specific slide by passing index of the slide as parameter.
@@ -1215,6 +1239,7 @@ var LightGallery = /** @class */ (function () {
1215
1239
  return;
1216
1240
  this.lgOpened = true;
1217
1241
  this.outer.removeClass('lg-hide-items');
1242
+ this.hideScrollbar();
1218
1243
  // Add display block, but still has opacity 0
1219
1244
  this.$container.addClass('lg-show');
1220
1245
  var itemsToBeInsertedToDom = this.getItemsToBeInsertedToDom(index, index);
@@ -2456,7 +2481,9 @@ var LightGallery = /** @class */ (function () {
2456
2481
  };
2457
2482
  LightGallery.prototype.trapFocus = function () {
2458
2483
  var _this = this;
2459
- this.$container.get().focus();
2484
+ this.$container.get().focus({
2485
+ preventScroll: true,
2486
+ });
2460
2487
  $LG(window).on("keydown.lg.global" + this.lgId, function (e) {
2461
2488
  if (!_this.lgOpened) {
2462
2489
  return;
@@ -2532,7 +2559,9 @@ var LightGallery = /** @class */ (function () {
2532
2559
  return 0;
2533
2560
  }
2534
2561
  this.LGel.trigger(lGEvents.beforeClose);
2535
- $LG(window).scrollTop(this.prevScrollTop);
2562
+ if (this.settings.resetScrollPosition && !this.settings.hideScrollbar) {
2563
+ $LG(window).scrollTop(this.prevScrollTop);
2564
+ }
2536
2565
  var currentItem = this.items[this.index];
2537
2566
  var transform;
2538
2567
  if (this.zoomFromOrigin && currentItem) {
@@ -2577,6 +2606,8 @@ var LightGallery = /** @class */ (function () {
2577
2606
  _this.outer.removeClass('lg-zoom-from-image');
2578
2607
  }
2579
2608
  _this.$container.removeClass('lg-show');
2609
+ // Reset scrollbar
2610
+ _this.resetScrollBar();
2580
2611
  // Need to remove inline opacity as it is used in the stylesheet as well
2581
2612
  _this.$backdrop
2582
2613
  .removeAttr('style')