lightgallery 2.5.0-beta.1 → 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 (80) hide show
  1. package/README.md +4 -4
  2. package/css/lightgallery-bundle.css +15 -0
  3. package/css/lightgallery-bundle.min.css +1 -1
  4. package/css/lightgallery-core.css +4 -0
  5. package/css/lightgallery.css +15 -0
  6. package/lg-settings.d.ts +14 -0
  7. package/lg-utils.d.ts +1 -0
  8. package/lib/lg-settings.js +3 -0
  9. package/lib/lg-settings.js.map +1 -1
  10. package/lib/lg-utils.js +8 -0
  11. package/lib/lg-utils.js.map +1 -1
  12. package/lib/lightgallery.js +66 -4
  13. package/lib/lightgallery.js.map +1 -1
  14. package/lib/plugins/video/lg-video-settings.js +1 -0
  15. package/lib/plugins/video/lg-video-settings.js.map +1 -1
  16. package/lib/plugins/video/lg-video.js +3 -1
  17. package/lib/plugins/video/lg-video.js.map +1 -1
  18. package/lightgallery.d.ts +5 -0
  19. package/lightgallery.es5.js +78 -5
  20. package/lightgallery.es5.js.map +1 -1
  21. package/lightgallery.min.js +2 -2
  22. package/lightgallery.umd.js +78 -5
  23. package/lightgallery.umd.js.map +1 -1
  24. package/lit/lightgallery.esm.js +7 -7
  25. package/lit/lightgallery.umd.js +3 -3
  26. package/package.json +1 -1
  27. package/plugins/autoplay/lg-autoplay.es5.js +1 -1
  28. package/plugins/autoplay/lg-autoplay.min.js +1 -1
  29. package/plugins/autoplay/lg-autoplay.umd.js +1 -1
  30. package/plugins/comment/lg-comment.es5.js +1 -1
  31. package/plugins/comment/lg-comment.min.js +1 -1
  32. package/plugins/comment/lg-comment.umd.js +1 -1
  33. package/plugins/fullscreen/lg-fullscreen.es5.js +1 -1
  34. package/plugins/fullscreen/lg-fullscreen.min.js +1 -1
  35. package/plugins/fullscreen/lg-fullscreen.umd.js +1 -1
  36. package/plugins/hash/lg-hash.es5.js +1 -1
  37. package/plugins/hash/lg-hash.min.js +1 -1
  38. package/plugins/hash/lg-hash.umd.js +1 -1
  39. package/plugins/mediumZoom/lg-medium-zoom.es5.js +1 -1
  40. package/plugins/mediumZoom/lg-medium-zoom.min.js +1 -1
  41. package/plugins/mediumZoom/lg-medium-zoom.umd.js +1 -1
  42. package/plugins/pager/lg-pager.es5.js +1 -1
  43. package/plugins/pager/lg-pager.min.js +1 -1
  44. package/plugins/pager/lg-pager.umd.js +1 -1
  45. package/plugins/relativeCaption/lg-relative-caption.es5.js +1 -1
  46. package/plugins/relativeCaption/lg-relative-caption.min.js +1 -1
  47. package/plugins/relativeCaption/lg-relative-caption.umd.js +1 -1
  48. package/plugins/rotate/lg-rotate.es5.js +1 -1
  49. package/plugins/rotate/lg-rotate.min.js +1 -1
  50. package/plugins/rotate/lg-rotate.umd.js +1 -1
  51. package/plugins/share/lg-share.es5.js +1 -1
  52. package/plugins/share/lg-share.min.js +1 -1
  53. package/plugins/share/lg-share.umd.js +1 -1
  54. package/plugins/thumbnail/lg-thumbnail.es5.js +1 -1
  55. package/plugins/thumbnail/lg-thumbnail.min.js +1 -1
  56. package/plugins/thumbnail/lg-thumbnail.umd.js +1 -1
  57. package/plugins/video/lg-video-settings.d.ts +6 -1
  58. package/plugins/video/lg-video.es5.js +5 -2
  59. package/plugins/video/lg-video.es5.js.map +1 -1
  60. package/plugins/video/lg-video.min.js +2 -2
  61. package/plugins/video/lg-video.umd.js +5 -2
  62. package/plugins/video/lg-video.umd.js.map +1 -1
  63. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.es5.js +1 -1
  64. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.min.js +1 -1
  65. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.umd.js +1 -1
  66. package/plugins/zoom/lg-zoom.es5.js +1 -1
  67. package/plugins/zoom/lg-zoom.min.js +1 -1
  68. package/plugins/zoom/lg-zoom.umd.js +1 -1
  69. package/react/Lightgallery.es5.js +78 -5
  70. package/react/Lightgallery.es5.js.map +1 -1
  71. package/react/Lightgallery.umd.js +78 -5
  72. package/react/Lightgallery.umd.js.map +1 -1
  73. package/scss/_lg-theme-default.scss +16 -0
  74. package/scss/lightgallery-core.scss +3 -0
  75. package/vue/LightGalleryVue.common.js +120 -31
  76. package/vue/LightGalleryVue.common.js.map +1 -1
  77. package/vue/LightGalleryVue.umd.js +120 -31
  78. package/vue/LightGalleryVue.umd.js.map +1 -1
  79. package/vue/LightGalleryVue.umd.min.js +2 -2
  80. package/vue/LightGalleryVue.umd.min.js.map +1 -1
@@ -241,3 +241,19 @@ body:not(.lg-from-hash) {
241
241
  }
242
242
  }
243
243
  }
244
+
245
+ .lg-icon {
246
+ &:focus-visible {
247
+ color: #fff;
248
+ border-radius: 3px;
249
+ outline: 1px dashed rgba(255, 255, 255, 0.6);
250
+ }
251
+ }
252
+ .lg-toolbar {
253
+ .lg-icon {
254
+ &:focus-visible {
255
+ border-radius: 8px;
256
+ outline-offset: -5px;
257
+ }
258
+ }
259
+ }
@@ -19,6 +19,9 @@
19
19
  .lg-on {
20
20
  scroll-behavior: unset;
21
21
  }
22
+ .lg-overlay-open {
23
+ overflow: hidden;
24
+ }
22
25
 
23
26
  // for idle state
24
27
  .lg-toolbar,
@@ -5863,6 +5863,8 @@ var lightGalleryCoreSettings = {
5863
5863
  defaultCaptionHeight: 0,
5864
5864
  ariaLabelledby: '',
5865
5865
  ariaDescribedby: '',
5866
+ resetScrollPosition: true,
5867
+ hideScrollbar: false,
5866
5868
  closable: true,
5867
5869
  swipeToClose: true,
5868
5870
  closeOnTap: true,
@@ -5871,6 +5873,7 @@ var lightGalleryCoreSettings = {
5871
5873
  loop: true,
5872
5874
  escKey: true,
5873
5875
  keyPress: true,
5876
+ trapFocus: true,
5874
5877
  controls: true,
5875
5878
  slideEndAnimation: true,
5876
5879
  hideControlOnEnd: false,
@@ -6509,6 +6512,7 @@ function $LG(selector) {
6509
6512
 
6510
6513
 
6511
6514
 
6515
+
6512
6516
  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
6513
6517
 
6514
6518
  function convertToData(attr) {
@@ -6688,6 +6692,14 @@ var utils = {
6688
6692
 
6689
6693
  return "<div class=\"lg-video-cont ".concat(videoClass, "\" style=\"").concat(videoContStyle, "\">\n <div class=\"lg-video-play-button\">\n <svg\n viewBox=\"0 0 20 20\"\n preserveAspectRatio=\"xMidYMid\"\n focusable=\"false\"\n aria-labelledby=\"").concat(playVideoString, "\"\n role=\"img\"\n class=\"lg-video-play-icon\"\n >\n <title>").concat(playVideoString, "</title>\n <polygon class=\"lg-video-play-icon-inner\" points=\"1,0 20,10 1,20\"></polygon>\n </svg>\n <svg class=\"lg-video-play-icon-bg\" viewBox=\"0 0 50 50\" focusable=\"false\">\n <circle cx=\"50%\" cy=\"50%\" r=\"20\"></circle></svg>\n <svg class=\"lg-video-play-icon-circle\" viewBox=\"0 0 50 50\" focusable=\"false\">\n <circle cx=\"50%\" cy=\"50%\" r=\"20\"></circle>\n </svg>\n </div>\n ").concat(dummyImg || '', "\n <img class=\"lg-object lg-video-poster\" src=\"").concat(_poster, "\" />\n </div>");
6690
6694
  },
6695
+ getFocusableElements: function getFocusableElements(container) {
6696
+ var elements = container.querySelectorAll('a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])');
6697
+ var visibleElements = [].filter.call(elements, function (element) {
6698
+ var style = window.getComputedStyle(element);
6699
+ return style.display !== 'none' && style.visibility !== 'hidden';
6700
+ });
6701
+ return visibleElements;
6702
+ },
6691
6703
 
6692
6704
  /**
6693
6705
  * @desc Create dynamic elements array from gallery items when dynamic option is false
@@ -6810,6 +6822,7 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
6810
6822
  this.currentItemsInDom = []; // Scroll top value before lightGallery is opened
6811
6823
 
6812
6824
  this.prevScrollTop = 0;
6825
+ this.bodyPaddingRight = 0;
6813
6826
  this.isDummyImageRemoved = false;
6814
6827
  this.dragOrSwipeEnabled = false;
6815
6828
  this.mediaContainerPosition = {
@@ -7203,6 +7216,34 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7203
7216
  return this.settings.dynamicEl || [];
7204
7217
  }
7205
7218
  }
7219
+ }, {
7220
+ key: "shouldHideScrollbar",
7221
+ value: function shouldHideScrollbar() {
7222
+ return this.settings.hideScrollbar && document.body === this.settings.container;
7223
+ }
7224
+ }, {
7225
+ key: "hideScrollbar",
7226
+ value: function hideScrollbar() {
7227
+ if (!this.shouldHideScrollbar()) {
7228
+ return;
7229
+ }
7230
+
7231
+ this.bodyPaddingRight = parseFloat($LG('body').style().paddingRight);
7232
+ var bodyRect = document.documentElement.getBoundingClientRect();
7233
+ var scrollbarWidth = window.innerWidth - bodyRect.width;
7234
+ $LG(document.body).css('padding-right', scrollbarWidth + this.bodyPaddingRight + 'px');
7235
+ $LG(document.body).addClass('lg-overlay-open');
7236
+ }
7237
+ }, {
7238
+ key: "resetScrollBar",
7239
+ value: function resetScrollBar() {
7240
+ if (!this.shouldHideScrollbar()) {
7241
+ return;
7242
+ }
7243
+
7244
+ $LG(document.body).css('padding-right', this.bodyPaddingRight + 'px');
7245
+ $LG(document.body).removeClass('lg-overlay-open');
7246
+ }
7206
7247
  /**
7207
7248
  * Open lightGallery.
7208
7249
  * Open gallery with specific slide by passing index of the slide as parameter.
@@ -7242,8 +7283,8 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7242
7283
  // prevent accidental double execution
7243
7284
  if (this.lgOpened) return;
7244
7285
  this.lgOpened = true;
7245
- this.outer.get().focus();
7246
- this.outer.removeClass('lg-hide-items'); // Add display block, but still has opacity 0
7286
+ this.outer.removeClass('lg-hide-items');
7287
+ this.hideScrollbar(); // Add display block, but still has opacity 0
7247
7288
 
7248
7289
  this.$container.addClass('lg-show');
7249
7290
  var itemsToBeInsertedToDom = this.getItemsToBeInsertedToDom(index, index);
@@ -7308,7 +7349,12 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7308
7349
  _this5.$backdrop.addClass('in');
7309
7350
 
7310
7351
  _this5.$container.addClass('lg-show-in');
7311
- }, 10); // lg-visible class resets gallery opacity to 1
7352
+ }, 10);
7353
+ setTimeout(function () {
7354
+ if (_this5.settings.trapFocus && document.body === _this5.settings.container) {
7355
+ _this5.trapFocus();
7356
+ }
7357
+ }, _this5.settings.backdropDuration + 50); // lg-visible class resets gallery opacity to 1
7312
7358
 
7313
7359
  if (!_this5.zoomFromOrigin || !transform) {
7314
7360
  setTimeout(function () {
@@ -8636,15 +8682,51 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8636
8682
  $element.off("click.lgcustom-item-".concat($element.attr('data-lg-id')));
8637
8683
  }
8638
8684
  }
8685
+ }, {
8686
+ key: "trapFocus",
8687
+ value: function trapFocus() {
8688
+ var _this26 = this;
8689
+
8690
+ this.$container.get().focus({
8691
+ preventScroll: true
8692
+ });
8693
+ $LG(window).on("keydown.lg.global".concat(this.lgId), function (e) {
8694
+ if (!_this26.lgOpened) {
8695
+ return;
8696
+ }
8697
+
8698
+ var isTabPressed = e.key === 'Tab' || e.keyCode === 9;
8699
+
8700
+ if (!isTabPressed) {
8701
+ return;
8702
+ }
8703
+
8704
+ var focusableEls = lg_utils.getFocusableElements(_this26.$container.get());
8705
+ var firstFocusableEl = focusableEls[0];
8706
+ var lastFocusableEl = focusableEls[focusableEls.length - 1];
8707
+
8708
+ if (e.shiftKey) {
8709
+ if (document.activeElement === firstFocusableEl) {
8710
+ lastFocusableEl.focus();
8711
+ e.preventDefault();
8712
+ }
8713
+ } else {
8714
+ if (document.activeElement === lastFocusableEl) {
8715
+ firstFocusableEl.focus();
8716
+ e.preventDefault();
8717
+ }
8718
+ }
8719
+ });
8720
+ }
8639
8721
  }, {
8640
8722
  key: "manageCloseGallery",
8641
8723
  value: function manageCloseGallery() {
8642
- var _this26 = this;
8724
+ var _this27 = this;
8643
8725
 
8644
8726
  if (!this.settings.closable) return;
8645
8727
  var mousedown = false;
8646
8728
  this.getElementById('lg-close').on('click.lg', function () {
8647
- _this26.closeGallery();
8729
+ _this27.closeGallery();
8648
8730
  });
8649
8731
 
8650
8732
  if (this.settings.closeOnTap) {
@@ -8653,7 +8735,7 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8653
8735
  this.outer.on('mousedown.lg', function (e) {
8654
8736
  var target = $LG(e.target);
8655
8737
 
8656
- if (_this26.isSlideElement(target)) {
8738
+ if (_this27.isSlideElement(target)) {
8657
8739
  mousedown = true;
8658
8740
  } else {
8659
8741
  mousedown = false;
@@ -8665,9 +8747,9 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8665
8747
  this.outer.on('mouseup.lg', function (e) {
8666
8748
  var target = $LG(e.target);
8667
8749
 
8668
- if (_this26.isSlideElement(target) && mousedown) {
8669
- if (!_this26.outer.hasClass('lg-dragging')) {
8670
- _this26.closeGallery();
8750
+ if (_this27.isSlideElement(target) && mousedown) {
8751
+ if (!_this27.outer.hasClass('lg-dragging')) {
8752
+ _this27.closeGallery();
8671
8753
  }
8672
8754
  }
8673
8755
  });
@@ -8688,14 +8770,18 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8688
8770
  }, {
8689
8771
  key: "closeGallery",
8690
8772
  value: function closeGallery(force) {
8691
- var _this27 = this;
8773
+ var _this28 = this;
8692
8774
 
8693
8775
  if (!this.lgOpened || !this.settings.closable && !force) {
8694
8776
  return 0;
8695
8777
  }
8696
8778
 
8697
8779
  this.LGel.trigger(lGEvents.beforeClose);
8698
- $LG(window).scrollTop(this.prevScrollTop);
8780
+
8781
+ if (this.settings.resetScrollPosition && !this.settings.hideScrollbar) {
8782
+ $LG(window).scrollTop(this.prevScrollTop);
8783
+ }
8784
+
8699
8785
  var currentItem = this.items[this.index];
8700
8786
  var transform;
8701
8787
 
@@ -8737,32 +8823,35 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8737
8823
  this.$container.removeClass('lg-show-in'); // Once the closign animation is completed and gallery is invisible
8738
8824
 
8739
8825
  setTimeout(function () {
8740
- if (_this27.zoomFromOrigin && transform) {
8741
- _this27.outer.removeClass('lg-zoom-from-image');
8826
+ if (_this28.zoomFromOrigin && transform) {
8827
+ _this28.outer.removeClass('lg-zoom-from-image');
8742
8828
  }
8743
8829
 
8744
- _this27.$container.removeClass('lg-show'); // Need to remove inline opacity as it is used in the stylesheet as well
8830
+ _this28.$container.removeClass('lg-show'); // Reset scrollbar
8745
8831
 
8746
8832
 
8747
- _this27.$backdrop.removeAttr('style').css('transition-duration', _this27.settings.backdropDuration + 'ms');
8833
+ _this28.resetScrollBar(); // Need to remove inline opacity as it is used in the stylesheet as well
8748
8834
 
8749
- _this27.outer.removeClass("lg-closing ".concat(_this27.settings.startClass));
8750
8835
 
8751
- _this27.getSlideItem(_this27.index).removeClass('lg-start-end-progress');
8836
+ _this28.$backdrop.removeAttr('style').css('transition-duration', _this28.settings.backdropDuration + 'ms');
8752
8837
 
8753
- _this27.$inner.empty();
8838
+ _this28.outer.removeClass("lg-closing ".concat(_this28.settings.startClass));
8754
8839
 
8755
- if (_this27.lgOpened) {
8756
- _this27.LGel.trigger(lGEvents.afterClose, {
8757
- instance: _this27
8840
+ _this28.getSlideItem(_this28.index).removeClass('lg-start-end-progress');
8841
+
8842
+ _this28.$inner.empty();
8843
+
8844
+ if (_this28.lgOpened) {
8845
+ _this28.LGel.trigger(lGEvents.afterClose, {
8846
+ instance: _this28
8758
8847
  });
8759
8848
  }
8760
8849
 
8761
- if (_this27.outer.get()) {
8762
- _this27.outer.get().blur();
8850
+ if (_this28.$container.get()) {
8851
+ _this28.$container.get().blur();
8763
8852
  }
8764
8853
 
8765
- _this27.lgOpened = false;
8854
+ _this28.lgOpened = false;
8766
8855
  }, removeTimeout + 100);
8767
8856
  return removeTimeout + 100;
8768
8857
  }
@@ -8848,21 +8937,21 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8848
8937
  }, {
8849
8938
  key: "destroy",
8850
8939
  value: function destroy() {
8851
- var _this28 = this;
8940
+ var _this29 = this;
8852
8941
 
8853
8942
  var closeTimeout = this.closeGallery(true);
8854
8943
  setTimeout(function () {
8855
- _this28.destroyModules(true);
8944
+ _this29.destroyModules(true);
8856
8945
 
8857
- if (!_this28.settings.dynamic) {
8858
- _this28.invalidateItems();
8946
+ if (!_this29.settings.dynamic) {
8947
+ _this29.invalidateItems();
8859
8948
  }
8860
8949
 
8861
- $LG(window).off(".lg.global".concat(_this28.lgId));
8950
+ $LG(window).off(".lg.global".concat(_this29.lgId));
8862
8951
 
8863
- _this28.LGel.off('.lg');
8952
+ _this29.LGel.off('.lg');
8864
8953
 
8865
- _this28.$container.remove();
8954
+ _this29.$container.remove();
8866
8955
  }, closeTimeout);
8867
8956
  return closeTimeout;
8868
8957
  }