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
@@ -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
+ }
@@ -5871,6 +5871,7 @@ var lightGalleryCoreSettings = {
5871
5871
  loop: true,
5872
5872
  escKey: true,
5873
5873
  keyPress: true,
5874
+ trapFocus: true,
5874
5875
  controls: true,
5875
5876
  slideEndAnimation: true,
5876
5877
  hideControlOnEnd: false,
@@ -6509,6 +6510,7 @@ function $LG(selector) {
6509
6510
 
6510
6511
 
6511
6512
 
6513
+
6512
6514
  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
6515
 
6514
6516
  function convertToData(attr) {
@@ -6688,6 +6690,14 @@ var utils = {
6688
6690
 
6689
6691
  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
6692
  },
6693
+ getFocusableElements: function getFocusableElements(container) {
6694
+ 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])');
6695
+ var visibleElements = [].filter.call(elements, function (element) {
6696
+ var style = window.getComputedStyle(element);
6697
+ return style.display !== 'none' && style.visibility !== 'hidden';
6698
+ });
6699
+ return visibleElements;
6700
+ },
6691
6701
 
6692
6702
  /**
6693
6703
  * @desc Create dynamic elements array from gallery items when dynamic option is false
@@ -7242,7 +7252,6 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7242
7252
  // prevent accidental double execution
7243
7253
  if (this.lgOpened) return;
7244
7254
  this.lgOpened = true;
7245
- this.outer.get().focus();
7246
7255
  this.outer.removeClass('lg-hide-items'); // Add display block, but still has opacity 0
7247
7256
 
7248
7257
  this.$container.addClass('lg-show');
@@ -7308,7 +7317,12 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
7308
7317
  _this5.$backdrop.addClass('in');
7309
7318
 
7310
7319
  _this5.$container.addClass('lg-show-in');
7311
- }, 10); // lg-visible class resets gallery opacity to 1
7320
+ }, 10);
7321
+ setTimeout(function () {
7322
+ if (_this5.settings.trapFocus && document.body === _this5.settings.container) {
7323
+ _this5.trapFocus();
7324
+ }
7325
+ }, _this5.settings.backdropDuration + 50); // lg-visible class resets gallery opacity to 1
7312
7326
 
7313
7327
  if (!_this5.zoomFromOrigin || !transform) {
7314
7328
  setTimeout(function () {
@@ -8636,15 +8650,49 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8636
8650
  $element.off("click.lgcustom-item-".concat($element.attr('data-lg-id')));
8637
8651
  }
8638
8652
  }
8653
+ }, {
8654
+ key: "trapFocus",
8655
+ value: function trapFocus() {
8656
+ var _this26 = this;
8657
+
8658
+ this.$container.get().focus();
8659
+ $LG(window).on("keydown.lg.global".concat(this.lgId), function (e) {
8660
+ if (!_this26.lgOpened) {
8661
+ return;
8662
+ }
8663
+
8664
+ var isTabPressed = e.key === 'Tab' || e.keyCode === 9;
8665
+
8666
+ if (!isTabPressed) {
8667
+ return;
8668
+ }
8669
+
8670
+ var focusableEls = lg_utils.getFocusableElements(_this26.$container.get());
8671
+ var firstFocusableEl = focusableEls[0];
8672
+ var lastFocusableEl = focusableEls[focusableEls.length - 1];
8673
+
8674
+ if (e.shiftKey) {
8675
+ if (document.activeElement === firstFocusableEl) {
8676
+ lastFocusableEl.focus();
8677
+ e.preventDefault();
8678
+ }
8679
+ } else {
8680
+ if (document.activeElement === lastFocusableEl) {
8681
+ firstFocusableEl.focus();
8682
+ e.preventDefault();
8683
+ }
8684
+ }
8685
+ });
8686
+ }
8639
8687
  }, {
8640
8688
  key: "manageCloseGallery",
8641
8689
  value: function manageCloseGallery() {
8642
- var _this26 = this;
8690
+ var _this27 = this;
8643
8691
 
8644
8692
  if (!this.settings.closable) return;
8645
8693
  var mousedown = false;
8646
8694
  this.getElementById('lg-close').on('click.lg', function () {
8647
- _this26.closeGallery();
8695
+ _this27.closeGallery();
8648
8696
  });
8649
8697
 
8650
8698
  if (this.settings.closeOnTap) {
@@ -8653,7 +8701,7 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8653
8701
  this.outer.on('mousedown.lg', function (e) {
8654
8702
  var target = $LG(e.target);
8655
8703
 
8656
- if (_this26.isSlideElement(target)) {
8704
+ if (_this27.isSlideElement(target)) {
8657
8705
  mousedown = true;
8658
8706
  } else {
8659
8707
  mousedown = false;
@@ -8665,9 +8713,9 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8665
8713
  this.outer.on('mouseup.lg', function (e) {
8666
8714
  var target = $LG(e.target);
8667
8715
 
8668
- if (_this26.isSlideElement(target) && mousedown) {
8669
- if (!_this26.outer.hasClass('lg-dragging')) {
8670
- _this26.closeGallery();
8716
+ if (_this27.isSlideElement(target) && mousedown) {
8717
+ if (!_this27.outer.hasClass('lg-dragging')) {
8718
+ _this27.closeGallery();
8671
8719
  }
8672
8720
  }
8673
8721
  });
@@ -8688,7 +8736,7 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8688
8736
  }, {
8689
8737
  key: "closeGallery",
8690
8738
  value: function closeGallery(force) {
8691
- var _this27 = this;
8739
+ var _this28 = this;
8692
8740
 
8693
8741
  if (!this.lgOpened || !this.settings.closable && !force) {
8694
8742
  return 0;
@@ -8737,32 +8785,32 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8737
8785
  this.$container.removeClass('lg-show-in'); // Once the closign animation is completed and gallery is invisible
8738
8786
 
8739
8787
  setTimeout(function () {
8740
- if (_this27.zoomFromOrigin && transform) {
8741
- _this27.outer.removeClass('lg-zoom-from-image');
8788
+ if (_this28.zoomFromOrigin && transform) {
8789
+ _this28.outer.removeClass('lg-zoom-from-image');
8742
8790
  }
8743
8791
 
8744
- _this27.$container.removeClass('lg-show'); // Need to remove inline opacity as it is used in the stylesheet as well
8792
+ _this28.$container.removeClass('lg-show'); // Need to remove inline opacity as it is used in the stylesheet as well
8745
8793
 
8746
8794
 
8747
- _this27.$backdrop.removeAttr('style').css('transition-duration', _this27.settings.backdropDuration + 'ms');
8795
+ _this28.$backdrop.removeAttr('style').css('transition-duration', _this28.settings.backdropDuration + 'ms');
8748
8796
 
8749
- _this27.outer.removeClass("lg-closing ".concat(_this27.settings.startClass));
8797
+ _this28.outer.removeClass("lg-closing ".concat(_this28.settings.startClass));
8750
8798
 
8751
- _this27.getSlideItem(_this27.index).removeClass('lg-start-end-progress');
8799
+ _this28.getSlideItem(_this28.index).removeClass('lg-start-end-progress');
8752
8800
 
8753
- _this27.$inner.empty();
8801
+ _this28.$inner.empty();
8754
8802
 
8755
- if (_this27.lgOpened) {
8756
- _this27.LGel.trigger(lGEvents.afterClose, {
8757
- instance: _this27
8803
+ if (_this28.lgOpened) {
8804
+ _this28.LGel.trigger(lGEvents.afterClose, {
8805
+ instance: _this28
8758
8806
  });
8759
8807
  }
8760
8808
 
8761
- if (_this27.outer.get()) {
8762
- _this27.outer.get().blur();
8809
+ if (_this28.$container.get()) {
8810
+ _this28.$container.get().blur();
8763
8811
  }
8764
8812
 
8765
- _this27.lgOpened = false;
8813
+ _this28.lgOpened = false;
8766
8814
  }, removeTimeout + 100);
8767
8815
  return removeTimeout + 100;
8768
8816
  }
@@ -8848,21 +8896,21 @@ var lightgallery_LightGallery = /*#__PURE__*/function () {
8848
8896
  }, {
8849
8897
  key: "destroy",
8850
8898
  value: function destroy() {
8851
- var _this28 = this;
8899
+ var _this29 = this;
8852
8900
 
8853
8901
  var closeTimeout = this.closeGallery(true);
8854
8902
  setTimeout(function () {
8855
- _this28.destroyModules(true);
8903
+ _this29.destroyModules(true);
8856
8904
 
8857
- if (!_this28.settings.dynamic) {
8858
- _this28.invalidateItems();
8905
+ if (!_this29.settings.dynamic) {
8906
+ _this29.invalidateItems();
8859
8907
  }
8860
8908
 
8861
- $LG(window).off(".lg.global".concat(_this28.lgId));
8909
+ $LG(window).off(".lg.global".concat(_this29.lgId));
8862
8910
 
8863
- _this28.LGel.off('.lg');
8911
+ _this29.LGel.off('.lg');
8864
8912
 
8865
- _this28.$container.remove();
8913
+ _this29.$container.remove();
8866
8914
  }, closeTimeout);
8867
8915
  return closeTimeout;
8868
8916
  }