next-flipbook 2.2.0 → 2.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 +8 -2
- package/dist/core/appearance/AppearanceStore.d.ts +18 -4
- package/dist/core/appearance/AppearanceStore.d.ts.map +1 -1
- package/dist/core/appearance/AppearanceStore.js +23 -5
- package/dist/core/appearance/AppearanceStore.js.map +1 -1
- package/dist/core/layout/scroll.d.ts +84 -0
- package/dist/core/layout/scroll.d.ts.map +1 -0
- package/dist/core/layout/scroll.js +104 -0
- package/dist/core/layout/scroll.js.map +1 -0
- package/dist/core/types.d.ts +9 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/zoom/ZoomController.d.ts +2 -0
- package/dist/core/zoom/ZoomController.d.ts.map +1 -1
- package/dist/core/zoom/ZoomController.js +6 -0
- package/dist/core/zoom/ZoomController.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react/components/FlipBook.d.ts.map +1 -1
- package/dist/react/components/FlipBook.js +25 -5
- package/dist/react/components/FlipBook.js.map +1 -1
- package/dist/react/components/FlipBookHeader.d.ts.map +1 -1
- package/dist/react/components/FlipBookHeader.js +1 -1
- package/dist/react/components/FlipBookHeader.js.map +1 -1
- package/dist/react/components/FlipBookMoreMenu.d.ts +1 -1
- package/dist/react/components/FlipBookMoreMenu.d.ts.map +1 -1
- package/dist/react/components/FlipBookMoreMenu.js +15 -4
- package/dist/react/components/FlipBookMoreMenu.js.map +1 -1
- package/dist/react/components/FlipBookProvider.d.ts.map +1 -1
- package/dist/react/components/FlipBookProvider.js +46 -10
- package/dist/react/components/FlipBookProvider.js.map +1 -1
- package/dist/react/components/FlipBookScrollStage.d.ts +14 -0
- package/dist/react/components/FlipBookScrollStage.d.ts.map +1 -0
- package/dist/react/components/FlipBookScrollStage.js +449 -0
- package/dist/react/components/FlipBookScrollStage.js.map +1 -0
- package/dist/react/components/FlipBookStage.d.ts +3 -3
- package/dist/react/components/FlipBookStage.d.ts.map +1 -1
- package/dist/react/components/FlipBookStage.js +14 -61
- package/dist/react/components/FlipBookStage.js.map +1 -1
- package/dist/react/components/FlipBookToolbar.d.ts.map +1 -1
- package/dist/react/components/FlipBookToolbar.js +2 -1
- package/dist/react/components/FlipBookToolbar.js.map +1 -1
- package/dist/react/components/FlipBookTour.d.ts.map +1 -1
- package/dist/react/components/FlipBookTour.js +5 -3
- package/dist/react/components/FlipBookTour.js.map +1 -1
- package/dist/react/components/StageMessages.d.ts +16 -0
- package/dist/react/components/StageMessages.d.ts.map +1 -0
- package/dist/react/components/StageMessages.js +28 -0
- package/dist/react/components/StageMessages.js.map +1 -0
- package/dist/react/context.d.ts +7 -0
- package/dist/react/context.d.ts.map +1 -1
- package/dist/react/context.js.map +1 -1
- package/dist/react/controller.d.ts.map +1 -1
- package/dist/react/controller.js +2 -0
- package/dist/react/controller.js.map +1 -1
- package/dist/react/hooks/useActiveHotspot.d.ts +14 -0
- package/dist/react/hooks/useActiveHotspot.d.ts.map +1 -0
- package/dist/react/hooks/useActiveHotspot.js +49 -0
- package/dist/react/hooks/useActiveHotspot.js.map +1 -0
- package/dist/react/hooks/useAppearance.d.ts +4 -2
- package/dist/react/hooks/useAppearance.d.ts.map +1 -1
- package/dist/react/hooks/useAppearance.js +7 -5
- package/dist/react/hooks/useAppearance.js.map +1 -1
- package/dist/react/hooks/useBookExtras.d.ts +1 -0
- package/dist/react/hooks/useBookExtras.d.ts.map +1 -1
- package/dist/react/hooks/useBookExtras.js +3 -0
- package/dist/react/hooks/useBookExtras.js.map +1 -1
- package/dist/react/hooks/useElementSize.d.ts +9 -1
- package/dist/react/hooks/useElementSize.d.ts.map +1 -1
- package/dist/react/hooks/useElementSize.js +11 -3
- package/dist/react/hooks/useElementSize.js.map +1 -1
- package/dist/react/hooks/useFlipBook.d.ts +3 -1
- package/dist/react/hooks/useFlipBook.d.ts.map +1 -1
- package/dist/react/hooks/useFlipBook.js +1 -0
- package/dist/react/hooks/useFlipBook.js.map +1 -1
- package/dist/react/hooks/useScrollGestures.d.ts +27 -0
- package/dist/react/hooks/useScrollGestures.d.ts.map +1 -0
- package/dist/react/hooks/useScrollGestures.js +144 -0
- package/dist/react/hooks/useScrollGestures.js.map +1 -0
- package/dist/react/icons.d.ts +1 -1
- package/dist/react/icons.d.ts.map +1 -1
- package/dist/react/icons.js +2 -0
- package/dist/react/icons.js.map +1 -1
- package/dist/react/locale.d.ts.map +1 -1
- package/dist/react/locale.js +4 -0
- package/dist/react/locale.js.map +1 -1
- package/dist/styles.css +7 -1
- package/dist/types/index.d.ts +44 -3
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore, } from "react";
|
|
4
|
+
import { anchoredScroll, contentWidth, dominantPage, pageTop, sameGeometry, scrollGeometry, scrollTopForPage, visibleRange, } from "../../core/layout/scroll.js";
|
|
5
|
+
import { useFlipBookContext } from "../context.js";
|
|
6
|
+
import { useActiveHotspot } from "../hooks/useActiveHotspot.js";
|
|
7
|
+
import { useElementSize } from "../hooks/useElementSize.js";
|
|
8
|
+
import { useEngineState } from "../hooks/useEngineState.js";
|
|
9
|
+
import { useIsoLayoutEffect } from "../hooks/useIsoLayoutEffect.js";
|
|
10
|
+
import { useLatest } from "../hooks/useLatest.js";
|
|
11
|
+
import { usePageAspect } from "../hooks/usePageAspect.js";
|
|
12
|
+
import { useScrollGestures } from "../hooks/useScrollGestures.js";
|
|
13
|
+
import { isImagePage, isPdfPage } from "../pages.js";
|
|
14
|
+
import { PAPER } from "../styles.js";
|
|
15
|
+
import { BookmarkRibbon } from "./BookmarkRibbon.js";
|
|
16
|
+
import { FlipBookLicenseMark } from "./FlipBookLicenseMark.js";
|
|
17
|
+
import { FlipBookPageView } from "./FlipBookPageView.js";
|
|
18
|
+
import { HotspotPopover } from "./HotspotPopover.js";
|
|
19
|
+
import { PageOverlays } from "./PageOverlays.js";
|
|
20
|
+
import { PasswordDialog } from "./PasswordDialog.js";
|
|
21
|
+
import { DefaultLoader, ErrorMessage, Message } from "./StageMessages.js";
|
|
22
|
+
/** How much of the book is kept in the page above and below the screen, in screens. */
|
|
23
|
+
const MARGIN = 0.75;
|
|
24
|
+
/** The most pages kept in the document at once, however small they are drawn. */
|
|
25
|
+
const MAX_PAGES_IN_DOCUMENT = 48;
|
|
26
|
+
/** How long a zoom keeps the point it was started at, once the gesture has stopped, in milliseconds. */
|
|
27
|
+
const ANCHOR_MS = 600;
|
|
28
|
+
// The sizes of the column are written to the content element as custom properties, so that a zoom
|
|
29
|
+
// moves every page with one write per frame and without rendering React again.
|
|
30
|
+
const PAGE_WIDTH = "--flipbook-scroll-page-width";
|
|
31
|
+
const PAGE_HEIGHT = "--flipbook-scroll-page-height";
|
|
32
|
+
const PAD = "--flipbook-scroll-pad";
|
|
33
|
+
const SLOT = "--flipbook-scroll-slot";
|
|
34
|
+
const HEIGHT = "--flipbook-scroll-height";
|
|
35
|
+
const samePageRange = (a, b) => a === b || (a !== null && b !== null && a.first === b.first && a.last === b.last);
|
|
36
|
+
function writeGeometry(element, geometry, pageCount) {
|
|
37
|
+
const style = element.style;
|
|
38
|
+
style.setProperty(PAGE_WIDTH, `${geometry.pageWidth}px`);
|
|
39
|
+
style.setProperty(PAGE_HEIGHT, `${geometry.pageHeight}px`);
|
|
40
|
+
style.setProperty(PAD, `${geometry.padding}px`);
|
|
41
|
+
style.setProperty(SLOT, `${geometry.slot}px`);
|
|
42
|
+
style.setProperty(HEIGHT, `${pageCount * geometry.pageHeight + Math.max(0, pageCount - 1) * geometry.gap + geometry.padding * 2}px`);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The pages one under another in a view that scrolls, as a document is normally read. The browser
|
|
46
|
+
* does the scrolling, so the wheel, touch, the scroll bar and the keys all work as they do
|
|
47
|
+
* everywhere else; this decides which pages are in the document, how big they are, and which one
|
|
48
|
+
* the engine is told the reader is on.
|
|
49
|
+
*
|
|
50
|
+
* Only the pages on screen and a margin round them exist as elements, so a book of 5,000 pages
|
|
51
|
+
* costs what one of 5 does. The engine still owns the current page, and everything that moves
|
|
52
|
+
* about the book (the thumbnails, search, bookmarks, the page box, the buttons) goes through it:
|
|
53
|
+
* this stage follows the engine, and reports back where the scroll has got to.
|
|
54
|
+
*/
|
|
55
|
+
export function FlipBookScrollStage(props) {
|
|
56
|
+
const { aspectRatio = "auto", padding = 16, renderLoader, renderError, renderEmpty } = props;
|
|
57
|
+
const { engine, imageLoader, pdf, zoom, bookmarks, search, interaction, document: documentState, password, pages, parts, locale, license, scroll, preloadPages, reportError, notifyReady, } = useFlipBookContext();
|
|
58
|
+
const state = useEngineState(engine);
|
|
59
|
+
const scrollerRef = useRef(null);
|
|
60
|
+
const contentRef = useRef(null);
|
|
61
|
+
// The room the pages have: the scroll bar is not part of it.
|
|
62
|
+
const view = useElementSize(scrollerRef, { clientBox: true });
|
|
63
|
+
const { aspect, error: aspectError, imageError } = usePageAspect(pages, aspectRatio, imageLoader, pdf);
|
|
64
|
+
const error = documentState.error ?? aspectError;
|
|
65
|
+
const measured = view !== null && view.width > 0 && view.height > 0;
|
|
66
|
+
const viewWidth = view?.width ?? 0;
|
|
67
|
+
const viewHeight = view?.height ?? 0;
|
|
68
|
+
// Layout effect: the engine is in the view that shows one page before the browser paints.
|
|
69
|
+
useIsoLayoutEffect(() => {
|
|
70
|
+
engine.configure({ view: "single" });
|
|
71
|
+
}, [engine]);
|
|
72
|
+
const ready = measured && aspect !== null && state.view === "single" && pages.length > 0;
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (ready)
|
|
75
|
+
notifyReady();
|
|
76
|
+
}, [ready, notifyReady]);
|
|
77
|
+
// Document failures are reported by the provider; this is the image-only case.
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (imageError)
|
|
80
|
+
reportError(imageError);
|
|
81
|
+
}, [imageError, reportError]);
|
|
82
|
+
// ---- what is shown instead of the pages ------------------------------------
|
|
83
|
+
let blocked = null;
|
|
84
|
+
if (password) {
|
|
85
|
+
blocked = (_jsx(PasswordDialog, { reason: password.reason, locale: locale, onSubmit: password.submit, onCancel: () => password.submit(null) }, password.id));
|
|
86
|
+
}
|
|
87
|
+
else if (error) {
|
|
88
|
+
blocked = renderError ? renderError(error) : _jsx(ErrorMessage, { error: error });
|
|
89
|
+
}
|
|
90
|
+
else if (pages.length === 0 && (documentState.status === "none" || documentState.status === "ready")) {
|
|
91
|
+
blocked = renderEmpty ? renderEmpty() : _jsx(Message, { role: "status", children: locale.empty });
|
|
92
|
+
}
|
|
93
|
+
else if (!ready) {
|
|
94
|
+
const progress = documentState.status === "loading" ? documentState.progress : null;
|
|
95
|
+
blocked = renderLoader ? (renderLoader({ progress })) : (_jsx(DefaultLoader, { progress: progress, label: locale.loading, template: locale.loadingProgress }));
|
|
96
|
+
}
|
|
97
|
+
const showing = blocked === null;
|
|
98
|
+
// ---- sizes ------------------------------------------------------------------
|
|
99
|
+
const gap = scroll.gap;
|
|
100
|
+
const maxPageWidth = scroll.maxPageWidth;
|
|
101
|
+
const zoomState = useSyncExternalStore(zoom.subscribe, zoom.getSnapshot, zoom.getSnapshot);
|
|
102
|
+
// The pages at the fitted size, and at the zoom that has settled. The live zoom, while a pinch
|
|
103
|
+
// is under way, is written straight to the page elements and does not come through here.
|
|
104
|
+
const fitted = useMemo(() => showing && aspect !== null
|
|
105
|
+
? scrollGeometry({ viewWidth, aspect, zoom: 1, padding, gap, maxPageWidth })
|
|
106
|
+
: null, [showing, aspect, viewWidth, padding, gap, maxPageWidth]);
|
|
107
|
+
const settled = useMemo(() => showing && aspect !== null
|
|
108
|
+
? scrollGeometry({ viewWidth, aspect, zoom: zoomState.zoom, padding, gap, maxPageWidth })
|
|
109
|
+
: null, [showing, aspect, viewWidth, zoomState.zoom, padding, gap, maxPageWidth]);
|
|
110
|
+
const fittedWidth = fitted === null ? 0 : Math.max(1, Math.round(fitted.pageWidth));
|
|
111
|
+
// PDF pages are drawn for the zoomed size once the zoom settles, so they stay sharp.
|
|
112
|
+
const renderWidth = settled === null ? 0 : Math.max(1, Math.round(settled.pageWidth));
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (renderWidth > 0)
|
|
115
|
+
pdf.setViewportWidth(renderWidth, fittedWidth);
|
|
116
|
+
}, [pdf, renderWidth, fittedWidth]);
|
|
117
|
+
// Images are fetched for the same size, unless `imageOptions.sharpenOnZoom` is off. Set before
|
|
118
|
+
// paint, so that the first page drawn already knows the size it is drawn at.
|
|
119
|
+
const imageWidth = imageLoader.getOptions().sharpenOnZoom ? renderWidth : fittedWidth;
|
|
120
|
+
useIsoLayoutEffect(() => {
|
|
121
|
+
imageLoader.setTargetWidth(imageWidth);
|
|
122
|
+
}, [imageLoader, imageWidth]);
|
|
123
|
+
// The controller keeps the number; the pan it also keeps is not used, because the view scrolls.
|
|
124
|
+
const fittedHeight = fitted?.pageHeight ?? 0;
|
|
125
|
+
useIsoLayoutEffect(() => {
|
|
126
|
+
if (fittedWidth > 0) {
|
|
127
|
+
zoom.setViewport({
|
|
128
|
+
viewWidth,
|
|
129
|
+
viewHeight,
|
|
130
|
+
contentWidth: fittedWidth,
|
|
131
|
+
contentHeight: fittedHeight,
|
|
132
|
+
padding,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}, [zoom, viewWidth, viewHeight, fittedWidth, fittedHeight, padding]);
|
|
136
|
+
// ---- which pages are in the document -----------------------------------------
|
|
137
|
+
const pagesRef = useLatest(pages);
|
|
138
|
+
const viewRef = useLatest(view);
|
|
139
|
+
const geometryRef = useRef(null);
|
|
140
|
+
const appliedRef = useRef(null);
|
|
141
|
+
/** The pages that show, as last prepared. */
|
|
142
|
+
const visibleRef = useRef(null);
|
|
143
|
+
/** The page the engine was last told about, or the scroll was last put at. */
|
|
144
|
+
const reportedRef = useRef(0);
|
|
145
|
+
/** False until the scroll has been put at the engine's page: nothing is reported before. */
|
|
146
|
+
const positionedRef = useRef(false);
|
|
147
|
+
/** Where the scroll last landed when it was moved by the stage: a move that is not the reader's. */
|
|
148
|
+
const landingRef = useRef(null);
|
|
149
|
+
const [shown, setShown] = useRangeState();
|
|
150
|
+
/** Prepares the pages on screen, then the ones the reader is likeliest to scroll to. */
|
|
151
|
+
const warm = useCallback((range) => {
|
|
152
|
+
if (range === null)
|
|
153
|
+
return;
|
|
154
|
+
const list = pagesRef.current;
|
|
155
|
+
const from = Math.max(1, range.first - preloadPages);
|
|
156
|
+
const to = Math.min(list.length, range.last + preloadPages);
|
|
157
|
+
const images = [];
|
|
158
|
+
for (let n = from; n <= to; n += 1) {
|
|
159
|
+
const page = list[n - 1];
|
|
160
|
+
if (isImagePage(page))
|
|
161
|
+
images.push(page);
|
|
162
|
+
}
|
|
163
|
+
imageLoader.preloadPages(images);
|
|
164
|
+
const visible = [];
|
|
165
|
+
for (let n = range.first; n <= range.last; n += 1)
|
|
166
|
+
visible.push(n);
|
|
167
|
+
pdf.focus({
|
|
168
|
+
visible,
|
|
169
|
+
total: list.length,
|
|
170
|
+
radius: preloadPages,
|
|
171
|
+
resolve: (position) => {
|
|
172
|
+
const page = pagesRef.current[position - 1];
|
|
173
|
+
return isPdfPage(page) ? { source: page.source, page: page.page } : null;
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
}, [imageLoader, pdf, pagesRef, preloadPages]);
|
|
177
|
+
/**
|
|
178
|
+
* Brings what is drawn up to date with where the view is scrolled: the pages in the document, the
|
|
179
|
+
* ones to prepare, and the page the engine is told about.
|
|
180
|
+
*/
|
|
181
|
+
const sync = useCallback(() => {
|
|
182
|
+
const scroller = scrollerRef.current;
|
|
183
|
+
const geometry = geometryRef.current;
|
|
184
|
+
const size = viewRef.current;
|
|
185
|
+
if (!scroller || !geometry || !size || !positionedRef.current)
|
|
186
|
+
return;
|
|
187
|
+
const count = pagesRef.current.length;
|
|
188
|
+
const height = scroller.clientHeight || size.height;
|
|
189
|
+
const top = scroller.scrollTop;
|
|
190
|
+
// A margin of a few screens each side, so that a page is there before it is scrolled to.
|
|
191
|
+
const margin = height * MARGIN;
|
|
192
|
+
const from = Math.max(0, top - margin);
|
|
193
|
+
const near = visibleRange(from, top + height + margin - from, count, geometry);
|
|
194
|
+
setShown(near !== null && near.last - near.first >= MAX_PAGES_IN_DOCUMENT
|
|
195
|
+
? { first: near.first, last: near.first + MAX_PAGES_IN_DOCUMENT - 1 }
|
|
196
|
+
: near);
|
|
197
|
+
const visible = visibleRange(top, height, count, geometry);
|
|
198
|
+
if (!samePageRange(visibleRef.current, visible)) {
|
|
199
|
+
visibleRef.current = visible;
|
|
200
|
+
warm(visible);
|
|
201
|
+
}
|
|
202
|
+
// A move the stage made itself is not the reader scrolling, and the page is already right.
|
|
203
|
+
const landing = landingRef.current;
|
|
204
|
+
if (landing !== null) {
|
|
205
|
+
if (Math.abs(top - landing) < 1.5)
|
|
206
|
+
return;
|
|
207
|
+
landingRef.current = null;
|
|
208
|
+
}
|
|
209
|
+
const atEnd = top > 0 && scroller.scrollHeight - top - height <= 1;
|
|
210
|
+
const page = count === 0 ? 0 : atEnd ? count : dominantPage(top, height, count, geometry);
|
|
211
|
+
if (page > 0 && page !== reportedRef.current) {
|
|
212
|
+
reportedRef.current = page;
|
|
213
|
+
engine.jumpToPage(page);
|
|
214
|
+
}
|
|
215
|
+
}, [engine, pagesRef, viewRef, warm, setShown]);
|
|
216
|
+
// Where a zoom is held still: the point the reader pinched or double-tapped, else the middle.
|
|
217
|
+
const anchorRef = useRef(null);
|
|
218
|
+
const anchorTimer = useRef(null);
|
|
219
|
+
const anchor = useCallback((point) => {
|
|
220
|
+
anchorRef.current = point;
|
|
221
|
+
if (anchorTimer.current !== null)
|
|
222
|
+
clearTimeout(anchorTimer.current);
|
|
223
|
+
anchorTimer.current =
|
|
224
|
+
point === null
|
|
225
|
+
? null
|
|
226
|
+
: setTimeout(() => {
|
|
227
|
+
anchorRef.current = null;
|
|
228
|
+
anchorTimer.current = null;
|
|
229
|
+
}, ANCHOR_MS);
|
|
230
|
+
}, []);
|
|
231
|
+
useEffect(() => () => {
|
|
232
|
+
if (anchorTimer.current !== null)
|
|
233
|
+
clearTimeout(anchorTimer.current);
|
|
234
|
+
}, []);
|
|
235
|
+
// Writes the sizes of the pages, and keeps the same spot of the book in place when they change:
|
|
236
|
+
// a zoom, or the view being resized. Declared before the effect that puts the scroll at the
|
|
237
|
+
// engine's page, which needs the sizes.
|
|
238
|
+
useIsoLayoutEffect(() => {
|
|
239
|
+
const scroller = scrollerRef.current;
|
|
240
|
+
const content = contentRef.current;
|
|
241
|
+
if (!showing || !scroller || !content || aspect === null) {
|
|
242
|
+
appliedRef.current = null;
|
|
243
|
+
geometryRef.current = null;
|
|
244
|
+
visibleRef.current = null;
|
|
245
|
+
positionedRef.current = false;
|
|
246
|
+
reportedRef.current = 0;
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const input = { viewWidth, aspect, padding, gap, maxPageWidth };
|
|
250
|
+
const count = pages.length;
|
|
251
|
+
const apply = (zoomValue, hold) => {
|
|
252
|
+
const next = scrollGeometry({ ...input, zoom: zoomValue });
|
|
253
|
+
const applied = appliedRef.current;
|
|
254
|
+
if (applied === null || applied.count !== count || !sameGeometry(applied.geometry, next)) {
|
|
255
|
+
writeGeometry(content, next, count);
|
|
256
|
+
if (applied !== null && positionedRef.current) {
|
|
257
|
+
const to = anchoredScroll({
|
|
258
|
+
scrollTop: scroller.scrollTop,
|
|
259
|
+
scrollLeft: scroller.scrollLeft,
|
|
260
|
+
focalX: hold.x,
|
|
261
|
+
focalY: hold.y,
|
|
262
|
+
viewWidth,
|
|
263
|
+
before: applied.geometry,
|
|
264
|
+
after: next,
|
|
265
|
+
});
|
|
266
|
+
scroller.scrollTop = to.top;
|
|
267
|
+
scroller.scrollLeft = to.left;
|
|
268
|
+
}
|
|
269
|
+
appliedRef.current = { geometry: next, count };
|
|
270
|
+
}
|
|
271
|
+
geometryRef.current = next;
|
|
272
|
+
sync();
|
|
273
|
+
};
|
|
274
|
+
// A resize keeps the top of the view where it is; a zoom keeps the point it was made about.
|
|
275
|
+
apply(zoom.getTransform().zoom, { x: viewWidth / 2, y: 0 });
|
|
276
|
+
return zoom.subscribeTransform((transform) => apply(transform.zoom, anchorRef.current ?? { x: viewWidth / 2, y: viewHeight / 2 }));
|
|
277
|
+
}, [showing, aspect, viewWidth, viewHeight, padding, gap, maxPageWidth, pages.length, zoom, sync]);
|
|
278
|
+
// The engine moved (the thumbnails, a search result, the buttons, a saved position): scroll there.
|
|
279
|
+
// The stage's own reports come back through here too, and are recognised by the page.
|
|
280
|
+
const currentPage = state.currentPage;
|
|
281
|
+
useIsoLayoutEffect(() => {
|
|
282
|
+
const scroller = scrollerRef.current;
|
|
283
|
+
const geometry = geometryRef.current;
|
|
284
|
+
if (!showing || !scroller || !geometry || currentPage < 1)
|
|
285
|
+
return;
|
|
286
|
+
if (positionedRef.current && currentPage === reportedRef.current)
|
|
287
|
+
return;
|
|
288
|
+
reportedRef.current = currentPage;
|
|
289
|
+
positionedRef.current = true;
|
|
290
|
+
scroller.scrollTop = scrollTopForPage(currentPage, geometry);
|
|
291
|
+
landingRef.current = scroller.scrollTop;
|
|
292
|
+
sync();
|
|
293
|
+
}, [showing, currentPage, sync]);
|
|
294
|
+
const savedBookmarks = useSyncExternalStore(bookmarks.subscribe, bookmarks.getSnapshot, bookmarks.getSnapshot);
|
|
295
|
+
const bookmarked = useMemo(() => new Set(savedBookmarks), [savedBookmarks]);
|
|
296
|
+
// Where the current search found text, drawn over the pages.
|
|
297
|
+
useSyncExternalStore(search.subscribe, search.getSnapshot, search.getSnapshot);
|
|
298
|
+
const highlights = search.getHighlights();
|
|
299
|
+
// The search moved to a match: the page is at the top of the view, and a match low on a tall page
|
|
300
|
+
// is below it. Scrolls just far enough to show it, once for each match.
|
|
301
|
+
const revealedRef = useRef(null);
|
|
302
|
+
useIsoLayoutEffect(() => {
|
|
303
|
+
const scroller = scrollerRef.current;
|
|
304
|
+
const geometry = geometryRef.current;
|
|
305
|
+
if (!showing || !scroller || !geometry || !positionedRef.current)
|
|
306
|
+
return;
|
|
307
|
+
let target = null;
|
|
308
|
+
for (const [page, list] of highlights) {
|
|
309
|
+
for (const highlight of list)
|
|
310
|
+
if (highlight.current)
|
|
311
|
+
target = { page, rect: highlight.rect };
|
|
312
|
+
}
|
|
313
|
+
if (target === null) {
|
|
314
|
+
revealedRef.current = null;
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
// Not yet at its page: the engine is about to be, and this runs again then.
|
|
318
|
+
if (target.page !== currentPage)
|
|
319
|
+
return;
|
|
320
|
+
const key = `${target.page}:${target.rect.x}:${target.rect.y}`;
|
|
321
|
+
if (key === revealedRef.current)
|
|
322
|
+
return;
|
|
323
|
+
revealedRef.current = key;
|
|
324
|
+
const top = pageTop(target.page, geometry) + target.rect.y * geometry.pageHeight;
|
|
325
|
+
const bottom = top + target.rect.height * geometry.pageHeight;
|
|
326
|
+
const height = scroller.clientHeight;
|
|
327
|
+
const room = 24;
|
|
328
|
+
if (top - room >= scroller.scrollTop && bottom + room <= scroller.scrollTop + height)
|
|
329
|
+
return;
|
|
330
|
+
scroller.scrollTop = Math.max(0, top - height / 3);
|
|
331
|
+
landingRef.current = scroller.scrollTop;
|
|
332
|
+
sync();
|
|
333
|
+
}, [showing, highlights, currentPage, sync]);
|
|
334
|
+
// Warm again when a document finishes loading or the size pages are fetched at changes.
|
|
335
|
+
useEffect(() => {
|
|
336
|
+
if (!showing)
|
|
337
|
+
return;
|
|
338
|
+
const again = () => warm(visibleRef.current);
|
|
339
|
+
const offPdf = pdf.subscribe(again);
|
|
340
|
+
const offImages = imageLoader.subscribe(again);
|
|
341
|
+
return () => {
|
|
342
|
+
offPdf();
|
|
343
|
+
offImages();
|
|
344
|
+
};
|
|
345
|
+
}, [showing, pdf, imageLoader, warm]);
|
|
346
|
+
useScrollGestures(scrollerRef, zoom, {
|
|
347
|
+
active: showing,
|
|
348
|
+
zoomEnabled: interaction.zoomEnabled,
|
|
349
|
+
doubleTapZoom: interaction.doubleTapZoom,
|
|
350
|
+
wheelZoom: interaction.wheelZoom,
|
|
351
|
+
}, anchor);
|
|
352
|
+
const numbers = [];
|
|
353
|
+
if (showing && shown !== null) {
|
|
354
|
+
for (let n = shown.first; n <= Math.min(shown.last, pages.length); n += 1)
|
|
355
|
+
numbers.push(n);
|
|
356
|
+
}
|
|
357
|
+
return (_jsxs("div", { "data-flipbook-stage": "", "data-flipbook-tour": "stage", className: parts.classNames.stage, style: {
|
|
358
|
+
position: "relative",
|
|
359
|
+
flex: "1 1 auto",
|
|
360
|
+
minWidth: 0,
|
|
361
|
+
minHeight: 0,
|
|
362
|
+
display: "flex",
|
|
363
|
+
alignItems: "center",
|
|
364
|
+
justifyContent: "center",
|
|
365
|
+
overflow: "hidden",
|
|
366
|
+
...parts.styles.stage,
|
|
367
|
+
}, children: [_jsx("div", { ref: scrollerRef, "data-flipbook-scroller": "", role: "region", "aria-label": locale.scrollArea, tabIndex: showing ? 0 : -1, onScroll: () => sync(), style: {
|
|
368
|
+
position: "absolute",
|
|
369
|
+
inset: 0,
|
|
370
|
+
overflowX: "auto",
|
|
371
|
+
// Always there, so that its width does not come and go with the length of the book and
|
|
372
|
+
// move the pages sideways.
|
|
373
|
+
overflowY: "scroll",
|
|
374
|
+
// The scroll is the view's own: pulling past the top must not reload the page.
|
|
375
|
+
overscrollBehavior: "contain",
|
|
376
|
+
// One finger scrolls; the pinch is ours.
|
|
377
|
+
touchAction: interaction.zoomEnabled ? "pan-x pan-y" : "auto",
|
|
378
|
+
WebkitOverflowScrolling: "touch",
|
|
379
|
+
// Kept measured while something else is shown, but out of the way.
|
|
380
|
+
visibility: showing ? "visible" : "hidden",
|
|
381
|
+
}, children: showing ? (_jsxs("div", { ref: contentRef, "data-flipbook-scroll-content": "", style: {
|
|
382
|
+
position: "relative",
|
|
383
|
+
width: `max(100%, calc(var(${PAGE_WIDTH}) + var(${PAD}) * 2))`,
|
|
384
|
+
height: `var(${HEIGHT})`,
|
|
385
|
+
}, children: [numbers.map((number) => (_jsx(ScrollPage, { page: pages[number - 1], pageNumber: number, renderWidth: renderWidth, imageWidth: imageWidth, bookmarked: bookmarked.has(number), highlights: highlights.get(number) }, number))), settled !== null ? _jsx(ScrollHotspotHost, { shown: shown, geometry: settled, viewWidth: viewWidth }) : null] })) : null }), blocked, license.state === "unlicensed" ? _jsx(FlipBookLicenseMark, {}) : null] }));
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* A range of pages in state that is only replaced when it changes. The setter is the same function
|
|
389
|
+
* for the life of the stage, which is what code run from scroll events needs.
|
|
390
|
+
*/
|
|
391
|
+
function useRangeState() {
|
|
392
|
+
const [range, setRange] = useState(null);
|
|
393
|
+
const set = useCallback((next) => setRange((previous) => (samePageRange(previous, next) ? previous : next)), [setRange]);
|
|
394
|
+
return [range, set];
|
|
395
|
+
}
|
|
396
|
+
// ---------------------------------------------------------------------------
|
|
397
|
+
const frame = {
|
|
398
|
+
background: PAPER,
|
|
399
|
+
border: "var(--flipbook-page-border, none)",
|
|
400
|
+
borderRadius: "var(--flipbook-page-radius, 0px)",
|
|
401
|
+
position: "absolute",
|
|
402
|
+
inset: 0,
|
|
403
|
+
overflow: "hidden",
|
|
404
|
+
boxSizing: "border-box",
|
|
405
|
+
};
|
|
406
|
+
/** One page of the column, in its place. Its size is the stage's, through custom properties. */
|
|
407
|
+
const ScrollPage = memo(function ScrollPage({ page, pageNumber, renderWidth, imageWidth, bookmarked, highlights, }) {
|
|
408
|
+
const { parts } = useFlipBookContext();
|
|
409
|
+
return (_jsx("div", { "data-flipbook-page": pageNumber, style: {
|
|
410
|
+
position: "absolute",
|
|
411
|
+
top: `calc(var(${PAD}) + ${pageNumber - 1} * var(${SLOT}))`,
|
|
412
|
+
left: `calc(50% - var(${PAGE_WIDTH}) / 2)`,
|
|
413
|
+
width: `var(${PAGE_WIDTH})`,
|
|
414
|
+
height: `var(${PAGE_HEIGHT})`,
|
|
415
|
+
// Not the book's shadow, which is large and would fall on the page above and below.
|
|
416
|
+
filter: "var(--flipbook-scroll-page-filter, drop-shadow(0 2px 8px rgba(0, 0, 0, 0.35)))",
|
|
417
|
+
}, children: _jsxs("div", { "data-flipbook-face": "", className: parts.classNames.page, style: { ...frame, ...parts.styles.page }, children: [_jsx(FlipBookPageView, { page: page, pageNumber: pageNumber, pageWidth: renderWidth, imageWidth: imageWidth }), _jsx(PageOverlays, { pageNumber: pageNumber, highlights: highlights }), bookmarked ? _jsx(BookmarkRibbon, { side: "right" }) : null] }) }));
|
|
418
|
+
});
|
|
419
|
+
const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
420
|
+
/**
|
|
421
|
+
* The popover of the open hotspot, next to it. It closes when its page is out of the document and
|
|
422
|
+
* when the pages are zoomed, which moves what it points at; the rest is `useActiveHotspot`.
|
|
423
|
+
*/
|
|
424
|
+
function ScrollHotspotHost({ shown, geometry, viewWidth, }) {
|
|
425
|
+
const { ui, locale, zoom } = useFlipBookContext();
|
|
426
|
+
const { hotspot, close } = useActiveHotspot();
|
|
427
|
+
const gone = hotspot !== null && (shown === null || hotspot.page < shown.first || hotspot.page > shown.last);
|
|
428
|
+
useEffect(() => {
|
|
429
|
+
if (gone)
|
|
430
|
+
ui.setHotspot(null);
|
|
431
|
+
}, [gone, ui]);
|
|
432
|
+
useEffect(() => zoom.subscribeTransform(() => {
|
|
433
|
+
if (ui.getSnapshot().hotspot)
|
|
434
|
+
ui.setHotspot(null);
|
|
435
|
+
}), [zoom, ui]);
|
|
436
|
+
if (!hotspot || hotspot.content === undefined || gone)
|
|
437
|
+
return null;
|
|
438
|
+
const { pageWidth, pageHeight } = geometry;
|
|
439
|
+
const width = contentWidth(viewWidth, geometry);
|
|
440
|
+
const maxWidth = Math.max(160, Math.min(320, pageWidth * 0.9));
|
|
441
|
+
const centre = width / 2 - pageWidth / 2 + (hotspot.x + hotspot.width / 2) * pageWidth;
|
|
442
|
+
const half = maxWidth / 2;
|
|
443
|
+
const left = width > maxWidth ? clamp(centre, half, width - half) : centre;
|
|
444
|
+
const above = hotspot.y + hotspot.height > 0.6;
|
|
445
|
+
const top0 = pageTop(hotspot.page, geometry);
|
|
446
|
+
const top = above ? top0 + hotspot.y * pageHeight - 8 : top0 + (hotspot.y + hotspot.height) * pageHeight + 8;
|
|
447
|
+
return (_jsx(HotspotPopover, { label: hotspot.label ?? locale.hotspot, closeLabel: locale.closeHotspot, left: left, top: top, above: above, maxWidth: maxWidth, onClose: close, children: hotspot.content }));
|
|
448
|
+
}
|
|
449
|
+
//# sourceMappingURL=FlipBookScrollStage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlipBookScrollStage.js","sourceRoot":"","sources":["../../../src/react/components/FlipBookScrollStage.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,IAAI,EACJ,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,EACR,oBAAoB,GAGrB,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,YAAY,GAGb,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,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OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC;IAC/C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC7C,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC,GAAG,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,UAAU,GAAG,CAAC,CAAC;IAE7G,OAAO,CACL,KAAC,cAAc,IACb,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,MAAM,CAAC,OAAO,EACtC,UAAU,EAAE,MAAM,CAAC,YAAY,EAC/B,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,KAAK,YAEb,OAAO,CAAC,OAAO,GACD,CAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { FlipBookStageProps } from "../../types/index.js";
|
|
2
2
|
/**
|
|
3
|
-
* Measures its container
|
|
4
|
-
* Nothing is drawn on the server or before the first
|
|
5
|
-
* no hydration mismatch and no flash of the wrong layout.
|
|
3
|
+
* Measures its container and draws the pages: as a book that turns, or, with `display="scroll"`,
|
|
4
|
+
* one under another in a view that scrolls. Nothing is drawn on the server or before the first
|
|
5
|
+
* measurement, so there is no hydration mismatch and no flash of the wrong layout.
|
|
6
6
|
*/
|
|
7
7
|
export declare function FlipBookStage(props: FlipBookStageProps): import("react").JSX.Element;
|
|
8
8
|
//# sourceMappingURL=FlipBookStage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlipBookStage.d.ts","sourceRoot":"","sources":["../../../src/react/components/FlipBookStage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FlipBookStage.d.ts","sourceRoot":"","sources":["../../../src/react/components/FlipBookStage.tsx"],"names":[],"mappings":"AAsCA,OAAO,KAAK,EAAgB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AA4B7E;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,+BAQtD"}
|
|
@@ -9,21 +9,29 @@ import { useElementSize } from "../hooks/useElementSize.js";
|
|
|
9
9
|
import { useEngineState } from "../hooks/useEngineState.js";
|
|
10
10
|
import { useIsoLayoutEffect } from "../hooks/useIsoLayoutEffect.js";
|
|
11
11
|
import { useGestures } from "../hooks/useGestures.js";
|
|
12
|
+
import { useActiveHotspot } from "../hooks/useActiveHotspot.js";
|
|
12
13
|
import { usePageAspect } from "../hooks/usePageAspect.js";
|
|
13
14
|
import { PAPER, SHADOW, backFaceTransform, bookTransform, castStyle, flatStyle, gradientFrom, leafTransform, spineStyle, } from "../styles.js";
|
|
14
|
-
import { formatMessage } from "../locale.js";
|
|
15
15
|
import { BookmarkRibbon } from "./BookmarkRibbon.js";
|
|
16
16
|
import { FlipBookPageView } from "./FlipBookPageView.js";
|
|
17
17
|
import { HotspotPopover } from "./HotspotPopover.js";
|
|
18
18
|
import { PageOverlays } from "./PageOverlays.js";
|
|
19
19
|
import { FlipBookLicenseMark } from "./FlipBookLicenseMark.js";
|
|
20
20
|
import { PasswordDialog } from "./PasswordDialog.js";
|
|
21
|
+
import { DefaultLoader, ErrorMessage, Message } from "./StageMessages.js";
|
|
22
|
+
import { FlipBookScrollStage } from "./FlipBookScrollStage.js";
|
|
21
23
|
/**
|
|
22
|
-
* Measures its container
|
|
23
|
-
* Nothing is drawn on the server or before the first
|
|
24
|
-
* no hydration mismatch and no flash of the wrong layout.
|
|
24
|
+
* Measures its container and draws the pages: as a book that turns, or, with `display="scroll"`,
|
|
25
|
+
* one under another in a view that scrolls. Nothing is drawn on the server or before the first
|
|
26
|
+
* measurement, so there is no hydration mismatch and no flash of the wrong layout.
|
|
25
27
|
*/
|
|
26
28
|
export function FlipBookStage(props) {
|
|
29
|
+
const { appearance } = useFlipBookContext();
|
|
30
|
+
const display = useSyncExternalStore(appearance.subscribe, () => appearance.getSnapshot().display, () => appearance.getSnapshot().display);
|
|
31
|
+
return display === "scroll" ? _jsx(FlipBookScrollStage, { ...props }) : _jsx(FlipBookBookStage, { ...props });
|
|
32
|
+
}
|
|
33
|
+
/** The pages as a book that turns. */
|
|
34
|
+
function FlipBookBookStage(props) {
|
|
27
35
|
const { aspectRatio = "auto", padding = 16, renderLoader, renderError, renderEmpty } = props;
|
|
28
36
|
const { engine, imageLoader, pdf, zoom, bookmarks, search, interaction, document: documentState, password, pages, mode, breakpoint, orientation, flipStyle, parts, locale, license, shadowStrength, reportError, notifyReady, } = useFlipBookContext();
|
|
29
37
|
const state = useEngineState(engine);
|
|
@@ -171,29 +179,6 @@ export function FlipBookStage(props) {
|
|
|
171
179
|
}, children: [content, license.state === "unlicensed" ? _jsx(FlipBookLicenseMark, {}) : null] }));
|
|
172
180
|
}
|
|
173
181
|
const zoomTransformValue = (transform) => `translate3d(${transform.panX}px, ${transform.panY}px, 0) scale(${transform.zoom})`;
|
|
174
|
-
function Message({ role, children }) {
|
|
175
|
-
return (_jsx("div", { role: role, style: {
|
|
176
|
-
padding: 24,
|
|
177
|
-
textAlign: "center",
|
|
178
|
-
font: "14px/1.5 var(--flipbook-font, system-ui, sans-serif)",
|
|
179
|
-
color: "var(--flipbook-toolbar-color, #1f2328)",
|
|
180
|
-
}, children: children }));
|
|
181
|
-
}
|
|
182
|
-
function DefaultLoader({ progress, label, template, }) {
|
|
183
|
-
const text = progress === null ? label : formatMessage(template, { percent: Math.round(progress * 100) });
|
|
184
|
-
return (_jsxs("div", { role: "status", style: {
|
|
185
|
-
display: "flex",
|
|
186
|
-
flexDirection: "column",
|
|
187
|
-
alignItems: "center",
|
|
188
|
-
gap: 10,
|
|
189
|
-
padding: 24,
|
|
190
|
-
font: "14px/1.5 var(--flipbook-font, system-ui, sans-serif)",
|
|
191
|
-
color: "var(--flipbook-toolbar-color, #1f2328)",
|
|
192
|
-
}, children: [_jsx("span", { children: text }), progress === null ? null : (_jsx("progress", { value: progress, max: 1, "aria-label": text, style: { width: 200, accentColor: "var(--flipbook-accent, #2563eb)" } }))] }));
|
|
193
|
-
}
|
|
194
|
-
function ErrorMessage({ error }) {
|
|
195
|
-
return _jsx(Message, { role: "alert", children: error.message });
|
|
196
|
-
}
|
|
197
182
|
/** How far a scripted turn draws the held corner up, as a share of the page breadth. */
|
|
198
183
|
const CURL_LIFT = 0.28;
|
|
199
184
|
const fill = { position: "absolute", inset: 0 };
|
|
@@ -526,18 +511,8 @@ const clampNumber = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
|
526
511
|
* else, and from its own button; Escape is handled by the viewer.
|
|
527
512
|
*/
|
|
528
513
|
function HotspotPopoverHost({ state, layout, orientation, }) {
|
|
529
|
-
const {
|
|
530
|
-
const
|
|
531
|
-
const hotspot = useMemo(() => {
|
|
532
|
-
if (!activeId)
|
|
533
|
-
return null;
|
|
534
|
-
for (const list of content.hotspotsByPage.values()) {
|
|
535
|
-
for (const candidate of list)
|
|
536
|
-
if (candidate.id === activeId)
|
|
537
|
-
return candidate;
|
|
538
|
-
}
|
|
539
|
-
return null;
|
|
540
|
-
}, [activeId, content.hotspotsByPage]);
|
|
514
|
+
const { ui, locale } = useFlipBookContext();
|
|
515
|
+
const { hotspot, close } = useActiveHotspot();
|
|
541
516
|
const turning = state.turn !== null;
|
|
542
517
|
const side = hotspot === null || turning
|
|
543
518
|
? null
|
|
@@ -551,21 +526,6 @@ function HotspotPopoverHost({ state, layout, orientation, }) {
|
|
|
551
526
|
if (hotspot && !turning && side === null)
|
|
552
527
|
ui.setHotspot(null);
|
|
553
528
|
}, [hotspot, turning, side, ui]);
|
|
554
|
-
useEffect(() => {
|
|
555
|
-
if (!hotspot)
|
|
556
|
-
return;
|
|
557
|
-
const onPress = (event) => {
|
|
558
|
-
const target = event.target;
|
|
559
|
-
if (target?.closest("[data-flipbook-popover]"))
|
|
560
|
-
return;
|
|
561
|
-
// Pressing the hotspot itself is its own toggle.
|
|
562
|
-
if (target?.closest("[data-flipbook-hotspot]")?.getAttribute("data-flipbook-hotspot") === hotspot.id)
|
|
563
|
-
return;
|
|
564
|
-
ui.setHotspot(null);
|
|
565
|
-
};
|
|
566
|
-
document.addEventListener("pointerdown", onPress, true);
|
|
567
|
-
return () => document.removeEventListener("pointerdown", onPress, true);
|
|
568
|
-
}, [hotspot, ui]);
|
|
569
529
|
if (!hotspot || hotspot.content === undefined || side === null)
|
|
570
530
|
return null;
|
|
571
531
|
const { pageWidth, pageHeight, bookWidth } = layout;
|
|
@@ -581,13 +541,6 @@ function HotspotPopoverHost({ state, layout, orientation, }) {
|
|
|
581
541
|
const top = above
|
|
582
542
|
? pageTop + hotspot.y * pageHeight - 8
|
|
583
543
|
: pageTop + (hotspot.y + hotspot.height) * pageHeight + 8;
|
|
584
|
-
const close = () => {
|
|
585
|
-
ui.setHotspot(null);
|
|
586
|
-
for (const element of document.querySelectorAll("[data-flipbook-hotspot]")) {
|
|
587
|
-
if (element.getAttribute("data-flipbook-hotspot") === hotspot.id)
|
|
588
|
-
element.focus();
|
|
589
|
-
}
|
|
590
|
-
};
|
|
591
544
|
return (_jsx(HotspotPopover, { label: hotspot.label ?? locale.hotspot, closeLabel: locale.closeHotspot, left: left, top: top, above: above, maxWidth: maxWidth, onClose: close, children: hotspot.content }));
|
|
592
545
|
}
|
|
593
546
|
//# sourceMappingURL=FlipBookStage.js.map
|