@hoangyell/gallery 1.0.7 → 1.0.8

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hoangyell/gallery",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Astro image gallery with lightbox, pyramid multi-row layout, and accessible controls.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/Gallery.astro CHANGED
@@ -506,6 +506,7 @@ if (resolvedRows <= 1 || galleryItems.length <= 1) {
506
506
  previousBodyTop: string;
507
507
  previousBodyWidth: string;
508
508
  previousHtmlOverflow: string;
509
+ previousHtmlScrollBehavior: string;
509
510
 
510
511
  constructor(el: HTMLElement) {
511
512
  this.gallery = el;
@@ -526,6 +527,7 @@ if (resolvedRows <= 1 || galleryItems.length <= 1) {
526
527
  this.previousBodyTop = "";
527
528
  this.previousBodyWidth = "";
528
529
  this.previousHtmlOverflow = "";
530
+ this.previousHtmlScrollBehavior = "";
529
531
 
530
532
  this.bind();
531
533
  document.addEventListener("astro:before-swap", this.forceClose);
@@ -684,6 +686,7 @@ if (resolvedRows <= 1 || galleryItems.length <= 1) {
684
686
  this.previousBodyTop = document.body.style.top;
685
687
  this.previousBodyWidth = document.body.style.width;
686
688
  this.previousHtmlOverflow = document.documentElement.style.overflow;
689
+ this.previousHtmlScrollBehavior = document.documentElement.style.scrollBehavior;
687
690
 
688
691
  document.documentElement.style.overflow = "hidden";
689
692
  document.body.style.overflow = "hidden";
@@ -700,7 +703,12 @@ if (resolvedRows <= 1 || galleryItems.length <= 1) {
700
703
  document.body.style.position = this.previousBodyPosition;
701
704
  document.body.style.top = this.previousBodyTop;
702
705
  document.body.style.width = this.previousBodyWidth;
703
- window.scrollTo(0, this.lockedScrollY);
706
+ document.documentElement.style.scrollBehavior = "auto";
707
+ window.scrollTo({ top: this.lockedScrollY, left: 0, behavior: "auto" });
708
+ requestAnimationFrame(() => {
709
+ document.documentElement.style.scrollBehavior =
710
+ this.previousHtmlScrollBehavior;
711
+ });
704
712
  this.lockedScrollY = -1;
705
713
  };
706
714