@reuse-sh/lightbox 0.3.0 → 0.4.0

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.3.0 | MIT License */
1
+ /*! @reuse-sh/lightbox 0.4.0 | 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/carousel.js CHANGED
@@ -1,6 +1,14 @@
1
+ const carouselInternals = Symbol.for("@reuse-sh/carousel internals");
1
2
  export function connectCarousel(lightbox, carousel, { slideOf = (index) => index } = {}) {
3
+ const strip = carousel[carouselInternals];
2
4
  const hold = (isHeld) => carousel.hold("lightbox", isHeld);
3
- const follow = (event) => carousel.goTo(slideOf(event.index), "instant");
5
+ const follow = ({ index }) => {
6
+ const slide = slideOf(index);
7
+ const visible = strip?.willKeepVisible?.(slide) ??
8
+ carousel.getState().visible.includes(slide);
9
+ if (!visible)
10
+ carousel.goTo(slide, "instant");
11
+ };
4
12
  const stops = [
5
13
  lightbox.on("open", () => hold(true)),
6
14
  lightbox.on("settle", follow),
package/dist/index.d.ts CHANGED
@@ -67,7 +67,10 @@ export interface LightboxListenOptions {
67
67
  }
68
68
  interface LightboxItemBase {
69
69
  alt?: string;
70
+ /** The caption's text, which the announcement reads. */
70
71
  caption?: string;
72
+ /** Builds the shown caption, such as one with a link or bold text, in place of the text. */
73
+ captionContent?: () => Node;
71
74
  /** The file's own size; without it the viewer fits the preview's proportions until the file decodes. */
72
75
  width?: number;
73
76
  height?: number;
@@ -77,11 +80,20 @@ interface LightboxItemBase {
77
80
  /** The tile the photo opens from and closes to, read again whenever the photo changes. */
78
81
  origin?: HTMLElement | null | (() => HTMLElement | null);
79
82
  }
83
+ /** Room around the photo, each side a fraction of the photo's width, like a CSS padding percentage. */
84
+ export interface LightboxMargins {
85
+ top?: number;
86
+ right?: number;
87
+ bottom?: number;
88
+ left?: number;
89
+ }
80
90
  export interface LightboxImageItem extends LightboxItemBase {
81
91
  type?: undefined;
82
92
  src: string;
83
93
  srcset?: string;
84
94
  sizes?: string;
95
+ /** Makes the photo and this room around it one picture that fits, zooms, pans and flies as a whole; renderContent draws in it. */
96
+ margins?: LightboxMargins;
85
97
  }
86
98
  export interface LightboxMediaItem extends LightboxItemBase {
87
99
  /** Picks the content module whose type matches, such as "video" for video(). */