lightgallery 2.5.0-beta.2 → 2.5.0-beta.3

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 (71) hide show
  1. package/README.md +3 -3
  2. package/css/lightgallery-bundle.css +11 -0
  3. package/css/lightgallery-bundle.min.css +1 -1
  4. package/css/lightgallery.css +11 -0
  5. package/lg-settings.d.ts +4 -0
  6. package/lg-utils.d.ts +1 -0
  7. package/lib/lg-settings.js +1 -0
  8. package/lib/lg-settings.js.map +1 -1
  9. package/lib/lg-utils.js +8 -0
  10. package/lib/lg-utils.js.map +1 -1
  11. package/lib/lightgallery.js +36 -3
  12. package/lib/lightgallery.js.map +1 -1
  13. package/lightgallery.d.ts +1 -0
  14. package/lightgallery.es5.js +46 -4
  15. package/lightgallery.es5.js.map +1 -1
  16. package/lightgallery.min.js +2 -2
  17. package/lightgallery.umd.js +46 -4
  18. package/lightgallery.umd.js.map +1 -1
  19. package/lit/lightgallery.esm.js +7 -7
  20. package/lit/lightgallery.umd.js +3 -3
  21. package/package.json +1 -1
  22. package/plugins/autoplay/lg-autoplay.es5.js +1 -1
  23. package/plugins/autoplay/lg-autoplay.min.js +1 -1
  24. package/plugins/autoplay/lg-autoplay.umd.js +1 -1
  25. package/plugins/comment/lg-comment.es5.js +1 -1
  26. package/plugins/comment/lg-comment.min.js +1 -1
  27. package/plugins/comment/lg-comment.umd.js +1 -1
  28. package/plugins/fullscreen/lg-fullscreen.es5.js +1 -1
  29. package/plugins/fullscreen/lg-fullscreen.min.js +1 -1
  30. package/plugins/fullscreen/lg-fullscreen.umd.js +1 -1
  31. package/plugins/hash/lg-hash.es5.js +1 -1
  32. package/plugins/hash/lg-hash.min.js +1 -1
  33. package/plugins/hash/lg-hash.umd.js +1 -1
  34. package/plugins/mediumZoom/lg-medium-zoom.es5.js +1 -1
  35. package/plugins/mediumZoom/lg-medium-zoom.min.js +1 -1
  36. package/plugins/mediumZoom/lg-medium-zoom.umd.js +1 -1
  37. package/plugins/pager/lg-pager.es5.js +1 -1
  38. package/plugins/pager/lg-pager.min.js +1 -1
  39. package/plugins/pager/lg-pager.umd.js +1 -1
  40. package/plugins/relativeCaption/lg-relative-caption.es5.js +1 -1
  41. package/plugins/relativeCaption/lg-relative-caption.min.js +1 -1
  42. package/plugins/relativeCaption/lg-relative-caption.umd.js +1 -1
  43. package/plugins/rotate/lg-rotate.es5.js +1 -1
  44. package/plugins/rotate/lg-rotate.min.js +1 -1
  45. package/plugins/rotate/lg-rotate.umd.js +1 -1
  46. package/plugins/share/lg-share.es5.js +1 -1
  47. package/plugins/share/lg-share.min.js +1 -1
  48. package/plugins/share/lg-share.umd.js +1 -1
  49. package/plugins/thumbnail/lg-thumbnail.es5.js +1 -1
  50. package/plugins/thumbnail/lg-thumbnail.min.js +1 -1
  51. package/plugins/thumbnail/lg-thumbnail.umd.js +1 -1
  52. package/plugins/video/lg-video.es5.js +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/vimeoThumbnail/lg-vimeo-thumbnail.es5.js +1 -1
  56. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.min.js +1 -1
  57. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.umd.js +1 -1
  58. package/plugins/zoom/lg-zoom.es5.js +1 -1
  59. package/plugins/zoom/lg-zoom.min.js +1 -1
  60. package/plugins/zoom/lg-zoom.umd.js +1 -1
  61. package/react/Lightgallery.es5.js +46 -4
  62. package/react/Lightgallery.es5.js.map +1 -1
  63. package/react/Lightgallery.umd.js +46 -4
  64. package/react/Lightgallery.umd.js.map +1 -1
  65. package/scss/_lg-theme-default.scss +16 -0
  66. package/vue/LightGalleryVue.common.js +77 -29
  67. package/vue/LightGalleryVue.common.js.map +1 -1
  68. package/vue/LightGalleryVue.umd.js +77 -29
  69. package/vue/LightGalleryVue.umd.js.map +1 -1
  70. package/vue/LightGalleryVue.umd.min.js +2 -2
  71. package/vue/LightGalleryVue.umd.min.js.map +1 -1
@@ -5880,6 +5880,7 @@ var lightGalleryCoreSettings = {
5880
5880
  loop: true,
5881
5881
  escKey: true,
5882
5882
  keyPress: true,
5883
+ trapFocus: true,
5883
5884
  controls: true,
5884
5885
  slideEndAnimation: true,
5885
5886
  hideControlOnEnd: false,
@@ -6518,6 +6519,7 @@ function $LG(selector) {
6518
6519
 
6519
6520
 
6520
6521
 
6522
+
6521
6523
  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
6522
6524
 
6523
6525
  function convertToData(attr) {
@@ -6697,6 +6699,14 @@ var utils = {
6697
6699
 
6698
6700
  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>");
6699
6701
  },
6702
+ getFocusableElements: function getFocusableElements(container) {
6703
+ 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])');
6704
+ var visibleElements = [].filter.call(elements, function (element) {
6705
+ var style = window.getComputedStyle(element);
6706
+ return style.display !== 'none' && style.visibility !== 'hidden';
6707
+ });
6708
+ return visibleElements;
6709
+ },
6700
6710
 
6701
6711
  /**
6702
6712
  * @desc Create dynamic elements array from gallery items when dynamic option is false
@@ -7251,7 +7261,6 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7251
7261
  // prevent accidental double execution
7252
7262
  if (this.lgOpened) return;
7253
7263
  this.lgOpened = true;
7254
- this.outer.get().focus();
7255
7264
  this.outer.removeClass('lg-hide-items'); // Add display block, but still has opacity 0
7256
7265
 
7257
7266
  this.$container.addClass('lg-show');
@@ -7317,7 +7326,12 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7317
7326
  _this5.$backdrop.addClass('in');
7318
7327
 
7319
7328
  _this5.$container.addClass('lg-show-in');
7320
- }, 10); // lg-visible class resets gallery opacity to 1
7329
+ }, 10);
7330
+ setTimeout(function () {
7331
+ if (_this5.settings.trapFocus && document.body === _this5.settings.container) {
7332
+ _this5.trapFocus();
7333
+ }
7334
+ }, _this5.settings.backdropDuration + 50); // lg-visible class resets gallery opacity to 1
7321
7335
 
7322
7336
  if (!_this5.zoomFromOrigin || !transform) {
7323
7337
  setTimeout(function () {
@@ -8645,15 +8659,49 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8645
8659
  $element.off("click.lgcustom-item-".concat($element.attr('data-lg-id')));
8646
8660
  }
8647
8661
  }
8662
+ }, {
8663
+ key: "trapFocus",
8664
+ value: function trapFocus() {
8665
+ var _this26 = this;
8666
+
8667
+ this.$container.get().focus();
8668
+ $LG(window).on("keydown.lg.global".concat(this.lgId), function (e) {
8669
+ if (!_this26.lgOpened) {
8670
+ return;
8671
+ }
8672
+
8673
+ var isTabPressed = e.key === 'Tab' || e.keyCode === 9;
8674
+
8675
+ if (!isTabPressed) {
8676
+ return;
8677
+ }
8678
+
8679
+ var focusableEls = lg_utils.getFocusableElements(_this26.$container.get());
8680
+ var firstFocusableEl = focusableEls[0];
8681
+ var lastFocusableEl = focusableEls[focusableEls.length - 1];
8682
+
8683
+ if (e.shiftKey) {
8684
+ if (document.activeElement === firstFocusableEl) {
8685
+ lastFocusableEl.focus();
8686
+ e.preventDefault();
8687
+ }
8688
+ } else {
8689
+ if (document.activeElement === lastFocusableEl) {
8690
+ firstFocusableEl.focus();
8691
+ e.preventDefault();
8692
+ }
8693
+ }
8694
+ });
8695
+ }
8648
8696
  }, {
8649
8697
  key: "manageCloseGallery",
8650
8698
  value: function manageCloseGallery() {
8651
- var _this26 = this;
8699
+ var _this27 = this;
8652
8700
 
8653
8701
  if (!this.settings.closable) return;
8654
8702
  var mousedown = false;
8655
8703
  this.getElementById('lg-close').on('click.lg', function () {
8656
- _this26.closeGallery();
8704
+ _this27.closeGallery();
8657
8705
  });
8658
8706
 
8659
8707
  if (this.settings.closeOnTap) {
@@ -8662,7 +8710,7 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8662
8710
  this.outer.on('mousedown.lg', function (e) {
8663
8711
  var target = $LG(e.target);
8664
8712
 
8665
- if (_this26.isSlideElement(target)) {
8713
+ if (_this27.isSlideElement(target)) {
8666
8714
  mousedown = true;
8667
8715
  } else {
8668
8716
  mousedown = false;
@@ -8674,9 +8722,9 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8674
8722
  this.outer.on('mouseup.lg', function (e) {
8675
8723
  var target = $LG(e.target);
8676
8724
 
8677
- if (_this26.isSlideElement(target) && mousedown) {
8678
- if (!_this26.outer.hasClass('lg-dragging')) {
8679
- _this26.closeGallery();
8725
+ if (_this27.isSlideElement(target) && mousedown) {
8726
+ if (!_this27.outer.hasClass('lg-dragging')) {
8727
+ _this27.closeGallery();
8680
8728
  }
8681
8729
  }
8682
8730
  });
@@ -8697,7 +8745,7 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8697
8745
  }, {
8698
8746
  key: "closeGallery",
8699
8747
  value: function closeGallery(force) {
8700
- var _this27 = this;
8748
+ var _this28 = this;
8701
8749
 
8702
8750
  if (!this.lgOpened || !this.settings.closable && !force) {
8703
8751
  return 0;
@@ -8746,32 +8794,32 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8746
8794
  this.$container.removeClass('lg-show-in'); // Once the closign animation is completed and gallery is invisible
8747
8795
 
8748
8796
  setTimeout(function () {
8749
- if (_this27.zoomFromOrigin && transform) {
8750
- _this27.outer.removeClass('lg-zoom-from-image');
8797
+ if (_this28.zoomFromOrigin && transform) {
8798
+ _this28.outer.removeClass('lg-zoom-from-image');
8751
8799
  }
8752
8800
 
8753
- _this27.$container.removeClass('lg-show'); // Need to remove inline opacity as it is used in the stylesheet as well
8801
+ _this28.$container.removeClass('lg-show'); // Need to remove inline opacity as it is used in the stylesheet as well
8754
8802
 
8755
8803
 
8756
- _this27.$backdrop.removeAttr('style').css('transition-duration', _this27.settings.backdropDuration + 'ms');
8804
+ _this28.$backdrop.removeAttr('style').css('transition-duration', _this28.settings.backdropDuration + 'ms');
8757
8805
 
8758
- _this27.outer.removeClass("lg-closing ".concat(_this27.settings.startClass));
8806
+ _this28.outer.removeClass("lg-closing ".concat(_this28.settings.startClass));
8759
8807
 
8760
- _this27.getSlideItem(_this27.index).removeClass('lg-start-end-progress');
8808
+ _this28.getSlideItem(_this28.index).removeClass('lg-start-end-progress');
8761
8809
 
8762
- _this27.$inner.empty();
8810
+ _this28.$inner.empty();
8763
8811
 
8764
- if (_this27.lgOpened) {
8765
- _this27.LGel.trigger(lGEvents.afterClose, {
8766
- instance: _this27
8812
+ if (_this28.lgOpened) {
8813
+ _this28.LGel.trigger(lGEvents.afterClose, {
8814
+ instance: _this28
8767
8815
  });
8768
8816
  }
8769
8817
 
8770
- if (_this27.outer.get()) {
8771
- _this27.outer.get().blur();
8818
+ if (_this28.$container.get()) {
8819
+ _this28.$container.get().blur();
8772
8820
  }
8773
8821
 
8774
- _this27.lgOpened = false;
8822
+ _this28.lgOpened = false;
8775
8823
  }, removeTimeout + 100);
8776
8824
  return removeTimeout + 100;
8777
8825
  }
@@ -8857,21 +8905,21 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8857
8905
  }, {
8858
8906
  key: "destroy",
8859
8907
  value: function destroy() {
8860
- var _this28 = this;
8908
+ var _this29 = this;
8861
8909
 
8862
8910
  var closeTimeout = this.closeGallery(true);
8863
8911
  setTimeout(function () {
8864
- _this28.destroyModules(true);
8912
+ _this29.destroyModules(true);
8865
8913
 
8866
- if (!_this28.settings.dynamic) {
8867
- _this28.invalidateItems();
8914
+ if (!_this29.settings.dynamic) {
8915
+ _this29.invalidateItems();
8868
8916
  }
8869
8917
 
8870
- $LG(window).off(".lg.global".concat(_this28.lgId));
8918
+ $LG(window).off(".lg.global".concat(_this29.lgId));
8871
8919
 
8872
- _this28.LGel.off('.lg');
8920
+ _this29.LGel.off('.lg');
8873
8921
 
8874
- _this28.$container.remove();
8922
+ _this29.$container.remove();
8875
8923
  }, closeTimeout);
8876
8924
  return closeTimeout;
8877
8925
  }