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
@@ -28,7 +28,7 @@ function __rest(s, e) {
28
28
  }
29
29
 
30
30
  /*!
31
- * lightgallery | 2.5.0-beta.2 | March 6th 2022
31
+ * lightgallery | 2.5.0-beta.3 | April 23rd 2022
32
32
  * http://www.lightgalleryjs.com/
33
33
  * Copyright (c) 2020 Sachin Neravath;
34
34
  * @license GPLv3
@@ -133,6 +133,7 @@ var lightGalleryCoreSettings = {
133
133
  loop: true,
134
134
  escKey: true,
135
135
  keyPress: true,
136
+ trapFocus: true,
136
137
  controls: true,
137
138
  slideEndAnimation: true,
138
139
  hideControlOnEnd: false,
@@ -749,6 +750,14 @@ var utils = {
749
750
  }
750
751
  return "<div class=\"lg-video-cont " + videoClass + "\" style=\"" + 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=\"" + playVideoString + "\"\n role=\"img\"\n class=\"lg-video-play-icon\"\n >\n <title>" + 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 " + (dummyImg || '') + "\n <img class=\"lg-object lg-video-poster\" src=\"" + _poster + "\" />\n </div>";
751
752
  },
753
+ getFocusableElements: function (container) {
754
+ 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])');
755
+ var visibleElements = [].filter.call(elements, function (element) {
756
+ var style = window.getComputedStyle(element);
757
+ return style.display !== 'none' && style.visibility !== 'hidden';
758
+ });
759
+ return visibleElements;
760
+ },
752
761
  /**
753
762
  * @desc Create dynamic elements array from gallery items when dynamic option is false
754
763
  * It helps to avoid frequent DOM interaction
@@ -1234,7 +1243,6 @@ var LightGallery = /** @class */ (function () {
1234
1243
  if (this.lgOpened)
1235
1244
  return;
1236
1245
  this.lgOpened = true;
1237
- this.outer.get().focus();
1238
1246
  this.outer.removeClass('lg-hide-items');
1239
1247
  // Add display block, but still has opacity 0
1240
1248
  this.$container.addClass('lg-show');
@@ -1294,6 +1302,12 @@ var LightGallery = /** @class */ (function () {
1294
1302
  _this.$backdrop.addClass('in');
1295
1303
  _this.$container.addClass('lg-show-in');
1296
1304
  }, 10);
1305
+ setTimeout(function () {
1306
+ if (_this.settings.trapFocus &&
1307
+ document.body === _this.settings.container) {
1308
+ _this.trapFocus();
1309
+ }
1310
+ }, _this.settings.backdropDuration + 50);
1297
1311
  // lg-visible class resets gallery opacity to 1
1298
1312
  if (!_this.zoomFromOrigin || !transform) {
1299
1313
  setTimeout(function () {
@@ -2469,6 +2483,34 @@ var LightGallery = /** @class */ (function () {
2469
2483
  $element.off("click.lgcustom-item-" + $element.attr('data-lg-id'));
2470
2484
  }
2471
2485
  };
2486
+ LightGallery.prototype.trapFocus = function () {
2487
+ var _this = this;
2488
+ this.$container.get().focus();
2489
+ $LG(window).on("keydown.lg.global" + this.lgId, function (e) {
2490
+ if (!_this.lgOpened) {
2491
+ return;
2492
+ }
2493
+ var isTabPressed = e.key === 'Tab' || e.keyCode === 9;
2494
+ if (!isTabPressed) {
2495
+ return;
2496
+ }
2497
+ var focusableEls = utils.getFocusableElements(_this.$container.get());
2498
+ var firstFocusableEl = focusableEls[0];
2499
+ var lastFocusableEl = focusableEls[focusableEls.length - 1];
2500
+ if (e.shiftKey) {
2501
+ if (document.activeElement === firstFocusableEl) {
2502
+ lastFocusableEl.focus();
2503
+ e.preventDefault();
2504
+ }
2505
+ }
2506
+ else {
2507
+ if (document.activeElement === lastFocusableEl) {
2508
+ firstFocusableEl.focus();
2509
+ e.preventDefault();
2510
+ }
2511
+ }
2512
+ });
2513
+ };
2472
2514
  LightGallery.prototype.manageCloseGallery = function () {
2473
2515
  var _this = this;
2474
2516
  if (!this.settings.closable)
@@ -2576,8 +2618,8 @@ var LightGallery = /** @class */ (function () {
2576
2618
  instance: _this,
2577
2619
  });
2578
2620
  }
2579
- if (_this.outer.get()) {
2580
- _this.outer.get().blur();
2621
+ if (_this.$container.get()) {
2622
+ _this.$container.get().blur();
2581
2623
  }
2582
2624
  _this.lgOpened = false;
2583
2625
  }, removeTimeout + 100);