@reuse-sh/lightbox 0.4.0 → 0.4.1

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.
@@ -1,3 +1,3 @@
1
- /*! @reuse-sh/lightbox 0.4.0 | MIT License */
1
+ /*! @reuse-sh/lightbox 0.4.1 | MIT License */
2
2
  function e(e,t,n){let r=t;return e.addEventListener(`play`,()=>r=!1,{signal:n}),{interactive:!0,ready:new Promise(t=>{e.addEventListener(`loadedmetadata`,t,{once:!0,signal:n}),e.addEventListener(`error`,t,{once:!0,signal:n})}),pause:()=>e.pause(),resume(){r&&(r=!1,e.play().catch(t=>{if(t.name===`NotAllowedError`)return e.muted=!0,e.play()}).catch(()=>{}))},unmount(){e.pause(),e.removeAttribute(`src`),e.load(),e.remove()}}}function t(){return{type:`video`,mount(t,{item:n,signal:r,autoplay:i}){let a=t.ownerDocument.createElement(`video`);return a.className=`re-lightbox-video`,a.controls=!0,a.playsInline=!0,a.preload=`metadata`,n.previewSrc&&(a.poster=n.previewSrc),a.src=n.src??``,n.alt&&a.setAttribute(`aria-label`,n.alt),t.append(a),e(a,i,r)}}}export{e as playerOf,t as video};
3
3
  //# sourceMappingURL=video.js.map
package/dist/index.js CHANGED
@@ -140,12 +140,15 @@ function lockScroll(doc) {
140
140
  y: win.scrollY,
141
141
  };
142
142
  locks.set(doc, lock);
143
- const gap = Math.max(0, win.innerWidth - doc.documentElement.clientWidth);
143
+ const root = doc.documentElement;
144
+ const width = root.offsetWidth;
145
+ doc.body.style.overflow = "hidden";
146
+ // Only the width the hidden scrollbar hands back: a reserved gutter or an overlay scrollbar hands back none.
147
+ const gap = Math.max(0, root.offsetWidth - width);
144
148
  if (gap)
145
149
  doc.body.style.paddingRight = `${Number.parseFloat(win.getComputedStyle(doc.body).paddingRight || "0") + gap}px`;
146
150
  // Fixed elements ignore body padding; they can add this gap themselves.
147
- doc.documentElement.style.setProperty("--re-scrollbar-gap", `${gap}px`);
148
- doc.body.style.overflow = "hidden";
151
+ root.style.setProperty("--re-scrollbar-gap", `${gap}px`);
149
152
  }
150
153
  lock.count++;
151
154
  let restored = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reuse-sh/lightbox",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "An image lightbox on native scrolling, with thumbnail transitions, zoom, pan, and pinch.",
5
5
  "keywords": [
6
6
  "reuse",