@jekrch/react-viewport-lightbox 0.1.0 → 0.3.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.
- package/README.md +64 -21
- package/dist/index.cjs +240 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +107 -6
- package/dist/index.d.ts +107 -6
- package/dist/index.js +240 -43
- package/dist/index.js.map +1 -1
- package/dist/styles.css +93 -7
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -19,8 +19,19 @@ interface ViewerItem<TData = unknown> {
|
|
|
19
19
|
/** Arbitrary per-slide payload, surfaced as `ctx.item.data` in render slots. */
|
|
20
20
|
data?: TData;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* A rectangle in viewport coordinates. Structurally compatible with the
|
|
24
|
+
* `DOMRect` returned by `element.getBoundingClientRect()`, so you can pass one
|
|
25
|
+
* straight through.
|
|
26
|
+
*/
|
|
27
|
+
interface ViewerRect {
|
|
28
|
+
top: number;
|
|
29
|
+
left: number;
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
}
|
|
22
33
|
/** Named, themeable regions of the viewer that accept a `className` override. */
|
|
23
|
-
type ViewerSlot = "root" | "backdrop" | "topBar" | "bottomBar" | "image" | "button" | "counter" | "navButton" | "navStart" | "navEnd" | "overlay";
|
|
34
|
+
type ViewerSlot = "root" | "backdrop" | "topBar" | "bottomBar" | "image" | "button" | "counter" | "navButton" | "navStart" | "navEnd" | "overlay" | "spinner";
|
|
24
35
|
/** Overridable control icons. Each is a React node rendered inside its button. */
|
|
25
36
|
interface ViewerIcons {
|
|
26
37
|
close: ReactNode;
|
|
@@ -39,6 +50,12 @@ interface ViewerContext<TData = unknown> {
|
|
|
39
50
|
index: number;
|
|
40
51
|
item: ViewerItem<TData>;
|
|
41
52
|
total: number;
|
|
53
|
+
/**
|
|
54
|
+
* True once the exit animation has started (after a close was requested,
|
|
55
|
+
* before `onClose` fires and the viewer unmounts). Lets overlay content fade
|
|
56
|
+
* out in step with the closing chrome instead of vanishing on unmount.
|
|
57
|
+
*/
|
|
58
|
+
closing: boolean;
|
|
42
59
|
hasPrev: boolean;
|
|
43
60
|
hasNext: boolean;
|
|
44
61
|
goPrev: () => void;
|
|
@@ -79,12 +96,55 @@ interface ImageViewerProps<TData = unknown> {
|
|
|
79
96
|
onNavigate?: (direction: "prev" | "next") => void;
|
|
80
97
|
/** Called AFTER the exit animation completes. */
|
|
81
98
|
onClose: () => void;
|
|
99
|
+
/**
|
|
100
|
+
* Called when the user presses Escape, before the viewer closes. Return
|
|
101
|
+
* `true` to mark the key handled and veto the default close — e.g. to dismiss
|
|
102
|
+
* a consumer overlay (drawer/graph) first, closing the viewer only on a
|
|
103
|
+
* second press. Return `false`/`undefined` to fall through to the default
|
|
104
|
+
* close.
|
|
105
|
+
*/
|
|
106
|
+
onEscape?: () => boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Enables a shared-element "zoom from thumbnail" open/close transition. Given
|
|
109
|
+
* the active index, return the on-screen rect of the source element (e.g. the
|
|
110
|
+
* gallery thumbnail) — typically `el.getBoundingClientRect()`. The active
|
|
111
|
+
* image expands from that rect on open and collapses back into it on close.
|
|
112
|
+
* Return `null` for an index with no on-screen source (or omit the prop
|
|
113
|
+
* entirely) to fall back to the default fade. Honors reduced-motion.
|
|
114
|
+
*/
|
|
115
|
+
getOriginRect?: (index: number) => ViewerRect | null;
|
|
82
116
|
/** Enable zoom/pan (wheel, pinch, double-tap). Default `true`. */
|
|
83
117
|
zoom?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Anchor wheel- and pinch-zoom on the pointer: scrolling zooms toward the
|
|
120
|
+
* cursor and a pinch zooms toward the gesture midpoint. Set `false` to zoom
|
|
121
|
+
* about the viewport center instead. Default `true`.
|
|
122
|
+
*/
|
|
123
|
+
zoomToCursor?: boolean;
|
|
84
124
|
/** Show the `index / total` counter. Default `true`. */
|
|
85
125
|
showCounter?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Show the built-in zoom in/out/reset buttons in the top bar. Independent of
|
|
128
|
+
* `zoom` (which governs the gesture behavior): set this `false` to keep
|
|
129
|
+
* zoom/pan gestures while a consumer overlay (e.g. an open graph/drawer that
|
|
130
|
+
* covers the image) temporarily owns the chrome. Default `true`.
|
|
131
|
+
*/
|
|
132
|
+
showZoomControls?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Suppress built-in arrow-key navigation (and the swipe commit) without
|
|
135
|
+
* tearing the viewer down. Useful while an overlay that has its own
|
|
136
|
+
* left/right handling is open. Does not hide the on-screen nav buttons.
|
|
137
|
+
* Default `false`.
|
|
138
|
+
*/
|
|
139
|
+
disableNavigation?: boolean;
|
|
86
140
|
/** Wrap around at the ends. Default `false`. */
|
|
87
141
|
loop?: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Close the viewer when the empty area around the image (the backdrop) is
|
|
144
|
+
* clicked. Clicks on the image, the bars, and the control buttons are
|
|
145
|
+
* unaffected. Default `false`.
|
|
146
|
+
*/
|
|
147
|
+
closeOnBackdropClick?: boolean;
|
|
88
148
|
/** Top-left title area. */
|
|
89
149
|
renderHeader?: (ctx: ViewerContext<TData>) => ReactNode;
|
|
90
150
|
/** Extra top-right buttons, rendered before the close button. */
|
|
@@ -97,6 +157,35 @@ interface ImageViewerProps<TData = unknown> {
|
|
|
97
157
|
renderNavStart?: (ctx: ViewerContext<TData>) => ReactNode;
|
|
98
158
|
/** Pinned to the RIGHT edge of the nav row; mirror of `renderNavStart`. */
|
|
99
159
|
renderNavEnd?: (ctx: ViewerContext<TData>) => ReactNode;
|
|
160
|
+
/**
|
|
161
|
+
* Where the `renderNavStart` / `renderNavEnd` slots sit relative to the
|
|
162
|
+
* prev/counter/next group:
|
|
163
|
+
* - `"edge"` (default): pinned to the left/right edges of the nav row (max
|
|
164
|
+
* 42rem), keeping the nav group optically centered regardless of slot width.
|
|
165
|
+
* - `"inline"`: placed directly flanking the nav group as one centered
|
|
166
|
+
* cluster, so a details/info toggle hugs the arrows.
|
|
167
|
+
*/
|
|
168
|
+
navSlotPlacement?: "edge" | "inline";
|
|
169
|
+
/**
|
|
170
|
+
* Size of the prev/next nav arrows (the bottom nav controls). A number is
|
|
171
|
+
* treated as pixels; a string is used verbatim (e.g. `"1.5rem"`). Sets the
|
|
172
|
+
* `--rvl-nav-height` custom property, so it can equally be themed in CSS.
|
|
173
|
+
* Defaults to `2.375rem` (38px) to match the comic-snaps viewer.
|
|
174
|
+
*/
|
|
175
|
+
navHeight?: number | string;
|
|
176
|
+
/**
|
|
177
|
+
* Gap between the bottom nav controls and the viewport's bottom edge. A number
|
|
178
|
+
* is treated as pixels; a string is used verbatim (e.g. `"2rem"`). Sets the
|
|
179
|
+
* `--rvl-nav-inset` custom property and is floored by the device safe-area
|
|
180
|
+
* inset. Defaults to `1.3rem`.
|
|
181
|
+
*/
|
|
182
|
+
navInset?: number | string;
|
|
183
|
+
/**
|
|
184
|
+
* Counter font size. By default the counter scales with `navHeight` (≈0.29×);
|
|
185
|
+
* set this to override that ratio with a fixed size. A number is treated as
|
|
186
|
+
* pixels; a string is used verbatim. Sets `--rvl-counter-font-size`.
|
|
187
|
+
*/
|
|
188
|
+
counterFontSize?: number | string;
|
|
100
189
|
/** Content below the nav row. */
|
|
101
190
|
renderFooter?: (ctx: ViewerContext<TData>) => ReactNode;
|
|
102
191
|
/** Drawers/graphs layered over the image. */
|
|
@@ -112,7 +201,7 @@ interface ImageViewerProps<TData = unknown> {
|
|
|
112
201
|
* `onIndexChange`; mount it when open and it runs its own enter/exit animation,
|
|
113
202
|
* calling `onClose` after the exit completes.
|
|
114
203
|
*/
|
|
115
|
-
declare function ImageViewer<TData = unknown>({ items, index, onIndexChange, onNavigate, onClose, zoom, showCounter, loop, renderHeader, renderHeaderActions, renderNavStart, renderNavEnd, renderFooter, renderOverlay, classNames, icons, ariaLabel, }: ImageViewerProps<TData>): react.JSX.Element | null;
|
|
204
|
+
declare function ImageViewer<TData = unknown>({ items, index, onIndexChange, onNavigate, onClose, onEscape, getOriginRect, zoom, zoomToCursor, showCounter, showZoomControls, disableNavigation, loop, closeOnBackdropClick, renderHeader, renderHeaderActions, renderNavStart, renderNavEnd, navSlotPlacement, navHeight, navInset, counterFontSize, renderFooter, renderOverlay, classNames, icons, ariaLabel, }: ImageViewerProps<TData>): react.JSX.Element | null;
|
|
116
205
|
|
|
117
206
|
interface NavButtonProps {
|
|
118
207
|
direction: "prev" | "next";
|
|
@@ -172,7 +261,12 @@ interface ImageZoomPanState {
|
|
|
172
261
|
*/
|
|
173
262
|
declare function useImageZoomPan(imgWrapperRef: RefObject<HTMLDivElement | null>, currentIndex: number,
|
|
174
263
|
/** When false, wheel-zoom and double-click-zoom are disabled. Default true. */
|
|
175
|
-
enabled?: boolean
|
|
264
|
+
enabled?: boolean,
|
|
265
|
+
/**
|
|
266
|
+
* When true (default), wheel-zoom anchors on the cursor. When false, it zooms
|
|
267
|
+
* about the viewport center.
|
|
268
|
+
*/
|
|
269
|
+
zoomToCursor?: boolean): ImageZoomPanState;
|
|
176
270
|
|
|
177
271
|
interface SlideNavigationState {
|
|
178
272
|
slideTrackRef: React.RefObject<HTMLDivElement | null>;
|
|
@@ -195,7 +289,9 @@ interface SlideNavigationState {
|
|
|
195
289
|
* preloaded/decoded before navigation commits so the swipe lands on a painted
|
|
196
290
|
* frame.
|
|
197
291
|
*/
|
|
198
|
-
declare function useSlideNavigation(items: ViewerItem[], currentIndex: number, onNavigate: (index: number) => void, onSlideStart?: (direction: "prev" | "next") => void
|
|
292
|
+
declare function useSlideNavigation(items: ViewerItem[], currentIndex: number, onNavigate: (index: number) => void, onSlideStart?: (direction: "prev" | "next") => void,
|
|
293
|
+
/** When true, navigation wraps around the ends instead of stopping. */
|
|
294
|
+
loop?: boolean): SlideNavigationState;
|
|
199
295
|
|
|
200
296
|
interface GestureHandlers {
|
|
201
297
|
handlePointerDown: (e: React.PointerEvent) => void;
|
|
@@ -215,7 +311,12 @@ interface GestureHandlers {
|
|
|
215
311
|
*/
|
|
216
312
|
declare function useGestureHandler(zoomPan: ImageZoomPanState, slide: SlideNavigationState, hasPrev: boolean, hasNext: boolean,
|
|
217
313
|
/** When false, pinch-zoom and double-tap-zoom are disabled. Default true. */
|
|
218
|
-
zoomEnabled?: boolean
|
|
314
|
+
zoomEnabled?: boolean,
|
|
315
|
+
/**
|
|
316
|
+
* When true (default), pinch-zoom anchors on the gesture midpoint. When
|
|
317
|
+
* false, it zooms about the viewport center.
|
|
318
|
+
*/
|
|
319
|
+
zoomToCursor?: boolean): GestureHandlers;
|
|
219
320
|
|
|
220
321
|
/**
|
|
221
322
|
* Measures the height of the top and bottom bars so the image area
|
|
@@ -274,4 +375,4 @@ declare function resolveSlideDirection({ offset, elapsedMs, viewportWidth, hasPr
|
|
|
274
375
|
*/
|
|
275
376
|
declare function useFocusTrap(containerRef: RefObject<HTMLElement | null>, active: boolean): void;
|
|
276
377
|
|
|
277
|
-
export { ChevronLeftIcon, ChevronRightIcon, CloseIcon, type Dims, type ImageTransform, ImageViewer, type ImageViewerProps, type ImageZoomPanState, MAX_SCALE, MIN_SCALE, NavButton, type ResolveSlideArgs, type SlideAction, type SlideNavigationState, type ViewerContext, type ViewerIcons, type ViewerItem, type ViewerSlot, ZoomInIcon, ZoomOutIcon, clampTranslate, defaultIcons, resolveSlideDirection, useBarMeasure, useBodyScrollLock, useFocusTrap, useGestureHandler, useImageZoomPan, useSlideNavigation };
|
|
378
|
+
export { ChevronLeftIcon, ChevronRightIcon, CloseIcon, type Dims, type ImageTransform, ImageViewer, type ImageViewerProps, type ImageZoomPanState, MAX_SCALE, MIN_SCALE, NavButton, type ResolveSlideArgs, type SlideAction, type SlideNavigationState, type ViewerContext, type ViewerIcons, type ViewerItem, type ViewerRect, type ViewerSlot, ZoomInIcon, ZoomOutIcon, clampTranslate, defaultIcons, resolveSlideDirection, useBarMeasure, useBodyScrollLock, useFocusTrap, useGestureHandler, useImageZoomPan, useSlideNavigation };
|
package/dist/index.d.ts
CHANGED
|
@@ -19,8 +19,19 @@ interface ViewerItem<TData = unknown> {
|
|
|
19
19
|
/** Arbitrary per-slide payload, surfaced as `ctx.item.data` in render slots. */
|
|
20
20
|
data?: TData;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* A rectangle in viewport coordinates. Structurally compatible with the
|
|
24
|
+
* `DOMRect` returned by `element.getBoundingClientRect()`, so you can pass one
|
|
25
|
+
* straight through.
|
|
26
|
+
*/
|
|
27
|
+
interface ViewerRect {
|
|
28
|
+
top: number;
|
|
29
|
+
left: number;
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
}
|
|
22
33
|
/** Named, themeable regions of the viewer that accept a `className` override. */
|
|
23
|
-
type ViewerSlot = "root" | "backdrop" | "topBar" | "bottomBar" | "image" | "button" | "counter" | "navButton" | "navStart" | "navEnd" | "overlay";
|
|
34
|
+
type ViewerSlot = "root" | "backdrop" | "topBar" | "bottomBar" | "image" | "button" | "counter" | "navButton" | "navStart" | "navEnd" | "overlay" | "spinner";
|
|
24
35
|
/** Overridable control icons. Each is a React node rendered inside its button. */
|
|
25
36
|
interface ViewerIcons {
|
|
26
37
|
close: ReactNode;
|
|
@@ -39,6 +50,12 @@ interface ViewerContext<TData = unknown> {
|
|
|
39
50
|
index: number;
|
|
40
51
|
item: ViewerItem<TData>;
|
|
41
52
|
total: number;
|
|
53
|
+
/**
|
|
54
|
+
* True once the exit animation has started (after a close was requested,
|
|
55
|
+
* before `onClose` fires and the viewer unmounts). Lets overlay content fade
|
|
56
|
+
* out in step with the closing chrome instead of vanishing on unmount.
|
|
57
|
+
*/
|
|
58
|
+
closing: boolean;
|
|
42
59
|
hasPrev: boolean;
|
|
43
60
|
hasNext: boolean;
|
|
44
61
|
goPrev: () => void;
|
|
@@ -79,12 +96,55 @@ interface ImageViewerProps<TData = unknown> {
|
|
|
79
96
|
onNavigate?: (direction: "prev" | "next") => void;
|
|
80
97
|
/** Called AFTER the exit animation completes. */
|
|
81
98
|
onClose: () => void;
|
|
99
|
+
/**
|
|
100
|
+
* Called when the user presses Escape, before the viewer closes. Return
|
|
101
|
+
* `true` to mark the key handled and veto the default close — e.g. to dismiss
|
|
102
|
+
* a consumer overlay (drawer/graph) first, closing the viewer only on a
|
|
103
|
+
* second press. Return `false`/`undefined` to fall through to the default
|
|
104
|
+
* close.
|
|
105
|
+
*/
|
|
106
|
+
onEscape?: () => boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Enables a shared-element "zoom from thumbnail" open/close transition. Given
|
|
109
|
+
* the active index, return the on-screen rect of the source element (e.g. the
|
|
110
|
+
* gallery thumbnail) — typically `el.getBoundingClientRect()`. The active
|
|
111
|
+
* image expands from that rect on open and collapses back into it on close.
|
|
112
|
+
* Return `null` for an index with no on-screen source (or omit the prop
|
|
113
|
+
* entirely) to fall back to the default fade. Honors reduced-motion.
|
|
114
|
+
*/
|
|
115
|
+
getOriginRect?: (index: number) => ViewerRect | null;
|
|
82
116
|
/** Enable zoom/pan (wheel, pinch, double-tap). Default `true`. */
|
|
83
117
|
zoom?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Anchor wheel- and pinch-zoom on the pointer: scrolling zooms toward the
|
|
120
|
+
* cursor and a pinch zooms toward the gesture midpoint. Set `false` to zoom
|
|
121
|
+
* about the viewport center instead. Default `true`.
|
|
122
|
+
*/
|
|
123
|
+
zoomToCursor?: boolean;
|
|
84
124
|
/** Show the `index / total` counter. Default `true`. */
|
|
85
125
|
showCounter?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Show the built-in zoom in/out/reset buttons in the top bar. Independent of
|
|
128
|
+
* `zoom` (which governs the gesture behavior): set this `false` to keep
|
|
129
|
+
* zoom/pan gestures while a consumer overlay (e.g. an open graph/drawer that
|
|
130
|
+
* covers the image) temporarily owns the chrome. Default `true`.
|
|
131
|
+
*/
|
|
132
|
+
showZoomControls?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Suppress built-in arrow-key navigation (and the swipe commit) without
|
|
135
|
+
* tearing the viewer down. Useful while an overlay that has its own
|
|
136
|
+
* left/right handling is open. Does not hide the on-screen nav buttons.
|
|
137
|
+
* Default `false`.
|
|
138
|
+
*/
|
|
139
|
+
disableNavigation?: boolean;
|
|
86
140
|
/** Wrap around at the ends. Default `false`. */
|
|
87
141
|
loop?: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Close the viewer when the empty area around the image (the backdrop) is
|
|
144
|
+
* clicked. Clicks on the image, the bars, and the control buttons are
|
|
145
|
+
* unaffected. Default `false`.
|
|
146
|
+
*/
|
|
147
|
+
closeOnBackdropClick?: boolean;
|
|
88
148
|
/** Top-left title area. */
|
|
89
149
|
renderHeader?: (ctx: ViewerContext<TData>) => ReactNode;
|
|
90
150
|
/** Extra top-right buttons, rendered before the close button. */
|
|
@@ -97,6 +157,35 @@ interface ImageViewerProps<TData = unknown> {
|
|
|
97
157
|
renderNavStart?: (ctx: ViewerContext<TData>) => ReactNode;
|
|
98
158
|
/** Pinned to the RIGHT edge of the nav row; mirror of `renderNavStart`. */
|
|
99
159
|
renderNavEnd?: (ctx: ViewerContext<TData>) => ReactNode;
|
|
160
|
+
/**
|
|
161
|
+
* Where the `renderNavStart` / `renderNavEnd` slots sit relative to the
|
|
162
|
+
* prev/counter/next group:
|
|
163
|
+
* - `"edge"` (default): pinned to the left/right edges of the nav row (max
|
|
164
|
+
* 42rem), keeping the nav group optically centered regardless of slot width.
|
|
165
|
+
* - `"inline"`: placed directly flanking the nav group as one centered
|
|
166
|
+
* cluster, so a details/info toggle hugs the arrows.
|
|
167
|
+
*/
|
|
168
|
+
navSlotPlacement?: "edge" | "inline";
|
|
169
|
+
/**
|
|
170
|
+
* Size of the prev/next nav arrows (the bottom nav controls). A number is
|
|
171
|
+
* treated as pixels; a string is used verbatim (e.g. `"1.5rem"`). Sets the
|
|
172
|
+
* `--rvl-nav-height` custom property, so it can equally be themed in CSS.
|
|
173
|
+
* Defaults to `2.375rem` (38px) to match the comic-snaps viewer.
|
|
174
|
+
*/
|
|
175
|
+
navHeight?: number | string;
|
|
176
|
+
/**
|
|
177
|
+
* Gap between the bottom nav controls and the viewport's bottom edge. A number
|
|
178
|
+
* is treated as pixels; a string is used verbatim (e.g. `"2rem"`). Sets the
|
|
179
|
+
* `--rvl-nav-inset` custom property and is floored by the device safe-area
|
|
180
|
+
* inset. Defaults to `1.3rem`.
|
|
181
|
+
*/
|
|
182
|
+
navInset?: number | string;
|
|
183
|
+
/**
|
|
184
|
+
* Counter font size. By default the counter scales with `navHeight` (≈0.29×);
|
|
185
|
+
* set this to override that ratio with a fixed size. A number is treated as
|
|
186
|
+
* pixels; a string is used verbatim. Sets `--rvl-counter-font-size`.
|
|
187
|
+
*/
|
|
188
|
+
counterFontSize?: number | string;
|
|
100
189
|
/** Content below the nav row. */
|
|
101
190
|
renderFooter?: (ctx: ViewerContext<TData>) => ReactNode;
|
|
102
191
|
/** Drawers/graphs layered over the image. */
|
|
@@ -112,7 +201,7 @@ interface ImageViewerProps<TData = unknown> {
|
|
|
112
201
|
* `onIndexChange`; mount it when open and it runs its own enter/exit animation,
|
|
113
202
|
* calling `onClose` after the exit completes.
|
|
114
203
|
*/
|
|
115
|
-
declare function ImageViewer<TData = unknown>({ items, index, onIndexChange, onNavigate, onClose, zoom, showCounter, loop, renderHeader, renderHeaderActions, renderNavStart, renderNavEnd, renderFooter, renderOverlay, classNames, icons, ariaLabel, }: ImageViewerProps<TData>): react.JSX.Element | null;
|
|
204
|
+
declare function ImageViewer<TData = unknown>({ items, index, onIndexChange, onNavigate, onClose, onEscape, getOriginRect, zoom, zoomToCursor, showCounter, showZoomControls, disableNavigation, loop, closeOnBackdropClick, renderHeader, renderHeaderActions, renderNavStart, renderNavEnd, navSlotPlacement, navHeight, navInset, counterFontSize, renderFooter, renderOverlay, classNames, icons, ariaLabel, }: ImageViewerProps<TData>): react.JSX.Element | null;
|
|
116
205
|
|
|
117
206
|
interface NavButtonProps {
|
|
118
207
|
direction: "prev" | "next";
|
|
@@ -172,7 +261,12 @@ interface ImageZoomPanState {
|
|
|
172
261
|
*/
|
|
173
262
|
declare function useImageZoomPan(imgWrapperRef: RefObject<HTMLDivElement | null>, currentIndex: number,
|
|
174
263
|
/** When false, wheel-zoom and double-click-zoom are disabled. Default true. */
|
|
175
|
-
enabled?: boolean
|
|
264
|
+
enabled?: boolean,
|
|
265
|
+
/**
|
|
266
|
+
* When true (default), wheel-zoom anchors on the cursor. When false, it zooms
|
|
267
|
+
* about the viewport center.
|
|
268
|
+
*/
|
|
269
|
+
zoomToCursor?: boolean): ImageZoomPanState;
|
|
176
270
|
|
|
177
271
|
interface SlideNavigationState {
|
|
178
272
|
slideTrackRef: React.RefObject<HTMLDivElement | null>;
|
|
@@ -195,7 +289,9 @@ interface SlideNavigationState {
|
|
|
195
289
|
* preloaded/decoded before navigation commits so the swipe lands on a painted
|
|
196
290
|
* frame.
|
|
197
291
|
*/
|
|
198
|
-
declare function useSlideNavigation(items: ViewerItem[], currentIndex: number, onNavigate: (index: number) => void, onSlideStart?: (direction: "prev" | "next") => void
|
|
292
|
+
declare function useSlideNavigation(items: ViewerItem[], currentIndex: number, onNavigate: (index: number) => void, onSlideStart?: (direction: "prev" | "next") => void,
|
|
293
|
+
/** When true, navigation wraps around the ends instead of stopping. */
|
|
294
|
+
loop?: boolean): SlideNavigationState;
|
|
199
295
|
|
|
200
296
|
interface GestureHandlers {
|
|
201
297
|
handlePointerDown: (e: React.PointerEvent) => void;
|
|
@@ -215,7 +311,12 @@ interface GestureHandlers {
|
|
|
215
311
|
*/
|
|
216
312
|
declare function useGestureHandler(zoomPan: ImageZoomPanState, slide: SlideNavigationState, hasPrev: boolean, hasNext: boolean,
|
|
217
313
|
/** When false, pinch-zoom and double-tap-zoom are disabled. Default true. */
|
|
218
|
-
zoomEnabled?: boolean
|
|
314
|
+
zoomEnabled?: boolean,
|
|
315
|
+
/**
|
|
316
|
+
* When true (default), pinch-zoom anchors on the gesture midpoint. When
|
|
317
|
+
* false, it zooms about the viewport center.
|
|
318
|
+
*/
|
|
319
|
+
zoomToCursor?: boolean): GestureHandlers;
|
|
219
320
|
|
|
220
321
|
/**
|
|
221
322
|
* Measures the height of the top and bottom bars so the image area
|
|
@@ -274,4 +375,4 @@ declare function resolveSlideDirection({ offset, elapsedMs, viewportWidth, hasPr
|
|
|
274
375
|
*/
|
|
275
376
|
declare function useFocusTrap(containerRef: RefObject<HTMLElement | null>, active: boolean): void;
|
|
276
377
|
|
|
277
|
-
export { ChevronLeftIcon, ChevronRightIcon, CloseIcon, type Dims, type ImageTransform, ImageViewer, type ImageViewerProps, type ImageZoomPanState, MAX_SCALE, MIN_SCALE, NavButton, type ResolveSlideArgs, type SlideAction, type SlideNavigationState, type ViewerContext, type ViewerIcons, type ViewerItem, type ViewerSlot, ZoomInIcon, ZoomOutIcon, clampTranslate, defaultIcons, resolveSlideDirection, useBarMeasure, useBodyScrollLock, useFocusTrap, useGestureHandler, useImageZoomPan, useSlideNavigation };
|
|
378
|
+
export { ChevronLeftIcon, ChevronRightIcon, CloseIcon, type Dims, type ImageTransform, ImageViewer, type ImageViewerProps, type ImageZoomPanState, MAX_SCALE, MIN_SCALE, NavButton, type ResolveSlideArgs, type SlideAction, type SlideNavigationState, type ViewerContext, type ViewerIcons, type ViewerItem, type ViewerRect, type ViewerSlot, ZoomInIcon, ZoomOutIcon, clampTranslate, defaultIcons, resolveSlideDirection, useBarMeasure, useBodyScrollLock, useFocusTrap, useGestureHandler, useImageZoomPan, useSlideNavigation };
|