react-3d-flipbook 1.1.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.
- package/LICENSE +21 -0
- package/README.md +1005 -0
- package/dist/components/BookmarksPanel.d.ts +21 -0
- package/dist/components/Flipbook.d.ts +5 -0
- package/dist/components/SearchPanel.d.ts +26 -0
- package/dist/components/TableOfContents.d.ts +13 -0
- package/dist/components/ThumbnailsPanel.d.ts +14 -0
- package/dist/components/WebGLPageFlip.d.ts +46 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/useAutoplay.d.ts +58 -0
- package/dist/hooks/useFlipbook.d.ts +48 -0
- package/dist/hooks/usePdfLoader.d.ts +127 -0
- package/dist/index.d.ts +1121 -0
- package/dist/index.esm.js +25056 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +25121 -0
- package/dist/index.js.map +1 -0
- package/dist/setupTests.d.ts +1 -0
- package/dist/types/index.d.ts +481 -0
- package/dist/utils/index.d.ts +131 -0
- package/dist/utils/pdfUtils.d.ts +158 -0
- package/package.json +122 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
export interface FlipbookPage {
|
|
2
|
+
/** Image source URL for the page */
|
|
3
|
+
src: string;
|
|
4
|
+
/** Thumbnail image URL */
|
|
5
|
+
thumb?: string;
|
|
6
|
+
/** Page title for table of contents */
|
|
7
|
+
title?: string;
|
|
8
|
+
/** HTML content to overlay on the page */
|
|
9
|
+
htmlContent?: string;
|
|
10
|
+
/** JSON data associated with the page */
|
|
11
|
+
json?: Record<string, unknown>;
|
|
12
|
+
/** Which side of a double page spread */
|
|
13
|
+
side?: "left" | "right";
|
|
14
|
+
/** Whether this is an empty/placeholder page */
|
|
15
|
+
empty?: boolean;
|
|
16
|
+
/** Page width in pixels (for landscape/portrait support) */
|
|
17
|
+
width?: number;
|
|
18
|
+
/** Page height in pixels (for landscape/portrait support) */
|
|
19
|
+
height?: number;
|
|
20
|
+
/** Page orientation - auto-detected from width/height if not specified */
|
|
21
|
+
orientation?: "portrait" | "landscape";
|
|
22
|
+
}
|
|
23
|
+
export interface TocItem {
|
|
24
|
+
title: string;
|
|
25
|
+
page: number;
|
|
26
|
+
children?: TocItem[];
|
|
27
|
+
}
|
|
28
|
+
export type ViewMode = "webgl";
|
|
29
|
+
export type SkinType = "dark" | "light" | "gradient";
|
|
30
|
+
export type LayoutType = "1" | "2" | "3" | "4";
|
|
31
|
+
export type HAlign = "left" | "center" | "right";
|
|
32
|
+
export type VAlign = "top" | "middle" | "bottom";
|
|
33
|
+
export interface ButtonConfig {
|
|
34
|
+
enabled?: boolean;
|
|
35
|
+
title?: string;
|
|
36
|
+
iconFA?: string;
|
|
37
|
+
iconM?: string;
|
|
38
|
+
iconFA_alt?: string;
|
|
39
|
+
iconM_alt?: string;
|
|
40
|
+
hAlign?: HAlign;
|
|
41
|
+
vAlign?: VAlign;
|
|
42
|
+
hideOnMobile?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface DownloadButtonConfig extends ButtonConfig {
|
|
45
|
+
url?: string;
|
|
46
|
+
name?: string;
|
|
47
|
+
forceDownload?: boolean;
|
|
48
|
+
openInNewWindow?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface CurrentPageConfig {
|
|
51
|
+
enabled?: boolean;
|
|
52
|
+
title?: string;
|
|
53
|
+
vAlign?: VAlign;
|
|
54
|
+
hAlign?: HAlign;
|
|
55
|
+
marginH?: number;
|
|
56
|
+
marginV?: number;
|
|
57
|
+
color?: string;
|
|
58
|
+
background?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface CloseButtonConfig extends ButtonConfig {
|
|
61
|
+
size?: number;
|
|
62
|
+
}
|
|
63
|
+
export interface ShareProviderConfig {
|
|
64
|
+
enabled?: boolean;
|
|
65
|
+
icon?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface ShareConfig {
|
|
68
|
+
whatsapp?: ShareProviderConfig;
|
|
69
|
+
twitter?: ShareProviderConfig;
|
|
70
|
+
facebook?: ShareProviderConfig;
|
|
71
|
+
pinterest?: ShareProviderConfig;
|
|
72
|
+
email?: ShareProviderConfig;
|
|
73
|
+
linkedin?: ShareProviderConfig;
|
|
74
|
+
digg?: ShareProviderConfig;
|
|
75
|
+
reddit?: ShareProviderConfig;
|
|
76
|
+
}
|
|
77
|
+
export interface PdfConfig {
|
|
78
|
+
annotationLayer?: boolean;
|
|
79
|
+
}
|
|
80
|
+
export interface FillPreloaderConfig {
|
|
81
|
+
enabled?: boolean;
|
|
82
|
+
imgEmpty?: string;
|
|
83
|
+
imgFull?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface LocalizationStrings {
|
|
86
|
+
print?: string;
|
|
87
|
+
printLeftPage?: string;
|
|
88
|
+
printRightPage?: string;
|
|
89
|
+
printCurrentPage?: string;
|
|
90
|
+
printAllPages?: string;
|
|
91
|
+
download?: string;
|
|
92
|
+
downloadLeftPage?: string;
|
|
93
|
+
downloadRightPage?: string;
|
|
94
|
+
downloadCurrentPage?: string;
|
|
95
|
+
downloadAllPages?: string;
|
|
96
|
+
bookmarks?: string;
|
|
97
|
+
bookmarkLeftPage?: string;
|
|
98
|
+
bookmarkRightPage?: string;
|
|
99
|
+
bookmarkCurrentPage?: string;
|
|
100
|
+
search?: string;
|
|
101
|
+
findInDocument?: string;
|
|
102
|
+
pagesFoundContaining?: string;
|
|
103
|
+
noMatches?: string;
|
|
104
|
+
matchesFound?: string;
|
|
105
|
+
thumbnails?: string;
|
|
106
|
+
tableOfContent?: string;
|
|
107
|
+
share?: string;
|
|
108
|
+
pressEscToClose?: string;
|
|
109
|
+
password?: string;
|
|
110
|
+
}
|
|
111
|
+
export interface MobileConfig {
|
|
112
|
+
shadows?: boolean;
|
|
113
|
+
pageSegmentsW?: number;
|
|
114
|
+
}
|
|
115
|
+
export interface AssetsConfig {
|
|
116
|
+
preloader?: string;
|
|
117
|
+
overlay?: string;
|
|
118
|
+
flipMp3?: string;
|
|
119
|
+
spinner?: string;
|
|
120
|
+
backgroundMp3?: string;
|
|
121
|
+
}
|
|
122
|
+
export interface LightboxConfig {
|
|
123
|
+
enabled?: boolean;
|
|
124
|
+
opened?: boolean;
|
|
125
|
+
fullscreen?: boolean;
|
|
126
|
+
closeOnClick?: boolean;
|
|
127
|
+
resetOnOpen?: boolean;
|
|
128
|
+
background?: string;
|
|
129
|
+
backgroundColor?: string;
|
|
130
|
+
backgroundPattern?: string;
|
|
131
|
+
backgroundImage?: string;
|
|
132
|
+
startPage?: number;
|
|
133
|
+
marginV?: number;
|
|
134
|
+
marginH?: number;
|
|
135
|
+
css?: string;
|
|
136
|
+
preload?: boolean;
|
|
137
|
+
showMenu?: boolean;
|
|
138
|
+
closeOnBack?: boolean;
|
|
139
|
+
}
|
|
140
|
+
export interface FlipbookOptions {
|
|
141
|
+
name?: string;
|
|
142
|
+
pages?: FlipbookPage[];
|
|
143
|
+
tableOfContent?: TocItem[];
|
|
144
|
+
tableOfContentCloseOnClick?: boolean;
|
|
145
|
+
thumbsCloseOnClick?: boolean;
|
|
146
|
+
deeplinkingEnabled?: boolean;
|
|
147
|
+
deeplinkingPrefix?: string;
|
|
148
|
+
assets?: AssetsConfig;
|
|
149
|
+
pdfUrl?: string | null;
|
|
150
|
+
pdfBrowserViewerIfMobile?: boolean;
|
|
151
|
+
pdfBrowserViewerIfIE?: boolean;
|
|
152
|
+
pdfBrowserViewerFullscreen?: boolean;
|
|
153
|
+
pdfBrowserViewerFullscreenTarget?: string;
|
|
154
|
+
rangeChunkSize?: number;
|
|
155
|
+
disableRange?: boolean;
|
|
156
|
+
disableStream?: boolean;
|
|
157
|
+
disableAutoFetch?: boolean;
|
|
158
|
+
pdfAutoLinks?: boolean;
|
|
159
|
+
pdf?: PdfConfig;
|
|
160
|
+
pdfTextLayer?: boolean;
|
|
161
|
+
annotationLayer?: boolean;
|
|
162
|
+
htmlLayer?: boolean;
|
|
163
|
+
rightToLeft?: boolean;
|
|
164
|
+
startPage?: number;
|
|
165
|
+
sound?: boolean;
|
|
166
|
+
backgroundColor?: string;
|
|
167
|
+
backgroundImage?: string;
|
|
168
|
+
backgroundPattern?: string;
|
|
169
|
+
backgroundTransparent?: boolean;
|
|
170
|
+
thumbSize?: number;
|
|
171
|
+
loadAllPages?: boolean;
|
|
172
|
+
loadPagesF?: number;
|
|
173
|
+
loadPagesB?: number;
|
|
174
|
+
autoplayOnStart?: boolean;
|
|
175
|
+
autoplayInterval?: number;
|
|
176
|
+
autoplayLoop?: boolean;
|
|
177
|
+
skin?: SkinType;
|
|
178
|
+
layout?: LayoutType;
|
|
179
|
+
skinColor?: string;
|
|
180
|
+
skinBackground?: string;
|
|
181
|
+
menuOverBook?: boolean;
|
|
182
|
+
menuFloating?: boolean;
|
|
183
|
+
menuBackground?: string;
|
|
184
|
+
menuShadow?: string;
|
|
185
|
+
menuMargin?: number;
|
|
186
|
+
menuPadding?: number;
|
|
187
|
+
menuTransparent?: boolean;
|
|
188
|
+
hideMenu?: boolean;
|
|
189
|
+
menu2OverBook?: boolean;
|
|
190
|
+
menu2Floating?: boolean;
|
|
191
|
+
menu2Background?: string;
|
|
192
|
+
menu2Shadow?: string;
|
|
193
|
+
menu2Margin?: number;
|
|
194
|
+
menu2Padding?: number;
|
|
195
|
+
menu2Transparent?: boolean;
|
|
196
|
+
btnColor?: string;
|
|
197
|
+
btnBackground?: string;
|
|
198
|
+
btnSize?: number;
|
|
199
|
+
btnRadius?: number;
|
|
200
|
+
btnMargin?: number;
|
|
201
|
+
btnPaddingV?: number;
|
|
202
|
+
btnPaddingH?: number;
|
|
203
|
+
btnShadow?: string;
|
|
204
|
+
btnTextShadow?: string;
|
|
205
|
+
btnBorder?: string;
|
|
206
|
+
btnColorHover?: string;
|
|
207
|
+
btnBackgroundHover?: string;
|
|
208
|
+
sideBtnColor?: string;
|
|
209
|
+
sideBtnBackground?: string;
|
|
210
|
+
sideBtnSize?: number;
|
|
211
|
+
sideBtnRadius?: number;
|
|
212
|
+
sideBtnMargin?: number;
|
|
213
|
+
sideBtnPaddingV?: number;
|
|
214
|
+
sideBtnPaddingH?: number;
|
|
215
|
+
sideBtnShadow?: string;
|
|
216
|
+
sideBtnTextShadow?: string;
|
|
217
|
+
sideBtnBorder?: string;
|
|
218
|
+
sideBtnColorHover?: string;
|
|
219
|
+
sideBtnBackgroundHover?: string;
|
|
220
|
+
floatingBtnColor?: string;
|
|
221
|
+
floatingBtnColorHover?: string;
|
|
222
|
+
floatingBtnBackground?: string;
|
|
223
|
+
floatingBtnBackgroundHover?: string;
|
|
224
|
+
floatingBtnSize?: number | null;
|
|
225
|
+
floatingBtnRadius?: number | null;
|
|
226
|
+
floatingBtnMargin?: number | null;
|
|
227
|
+
floatingBtnPadding?: number | null;
|
|
228
|
+
floatingBtnShadow?: string;
|
|
229
|
+
floatingBtnTextShadow?: string;
|
|
230
|
+
floatingBtnBorder?: string;
|
|
231
|
+
currentPage?: CurrentPageConfig;
|
|
232
|
+
btnFirst?: ButtonConfig;
|
|
233
|
+
btnPrev?: ButtonConfig;
|
|
234
|
+
btnNext?: ButtonConfig;
|
|
235
|
+
btnLast?: ButtonConfig;
|
|
236
|
+
btnZoomIn?: ButtonConfig;
|
|
237
|
+
btnZoomOut?: ButtonConfig;
|
|
238
|
+
btnRotateLeft?: ButtonConfig;
|
|
239
|
+
btnRotateRight?: ButtonConfig;
|
|
240
|
+
btnAutoplay?: ButtonConfig;
|
|
241
|
+
btnSearch?: ButtonConfig;
|
|
242
|
+
btnSelect?: ButtonConfig;
|
|
243
|
+
btnBookmark?: ButtonConfig;
|
|
244
|
+
btnToc?: ButtonConfig;
|
|
245
|
+
btnThumbs?: ButtonConfig;
|
|
246
|
+
btnShare?: ButtonConfig;
|
|
247
|
+
btnPrint?: ButtonConfig;
|
|
248
|
+
btnDownloadPages?: DownloadButtonConfig;
|
|
249
|
+
btnDownloadPdf?: DownloadButtonConfig;
|
|
250
|
+
btnSound?: ButtonConfig;
|
|
251
|
+
btnExpand?: ButtonConfig;
|
|
252
|
+
btnClose?: CloseButtonConfig;
|
|
253
|
+
btnOrder?: string[];
|
|
254
|
+
btnShareIfMobile?: boolean;
|
|
255
|
+
btnSoundIfMobile?: boolean;
|
|
256
|
+
btnPrintIfMobile?: boolean;
|
|
257
|
+
sideNavigationButtons?: boolean;
|
|
258
|
+
shareUrl?: string;
|
|
259
|
+
shareTitle?: string;
|
|
260
|
+
shareImage?: string;
|
|
261
|
+
share?: ShareConfig;
|
|
262
|
+
pageTextureSize?: number;
|
|
263
|
+
pageTextureSizeSmall?: number;
|
|
264
|
+
thumbTextureSize?: number;
|
|
265
|
+
pageTextureSizeMobile?: number;
|
|
266
|
+
pageTextureSizeMobileSmall?: number;
|
|
267
|
+
viewMode?: ViewMode;
|
|
268
|
+
singlePageMode?: boolean;
|
|
269
|
+
singlePageModeIfMobile?: boolean;
|
|
270
|
+
zoomMin?: number;
|
|
271
|
+
zoomMax2?: number;
|
|
272
|
+
zoomSize?: number;
|
|
273
|
+
zoomStep?: number;
|
|
274
|
+
zoomTime?: number;
|
|
275
|
+
zoomReset?: boolean;
|
|
276
|
+
zoomResetTime?: number;
|
|
277
|
+
wheelDisabledNotFullscreen?: boolean;
|
|
278
|
+
arrowsDisabledNotFullscreen?: boolean;
|
|
279
|
+
arrowsAlwaysEnabledForNavigation?: boolean;
|
|
280
|
+
touchSwipeEnabled?: boolean;
|
|
281
|
+
doubleClickZoomDisabled?: boolean;
|
|
282
|
+
pageDragDisabled?: boolean;
|
|
283
|
+
rightClickEnabled?: boolean;
|
|
284
|
+
responsiveView?: boolean;
|
|
285
|
+
responsiveViewRatio?: number;
|
|
286
|
+
responsiveViewTreshold?: number;
|
|
287
|
+
minPixelRatio?: number;
|
|
288
|
+
pageFlipDuration?: number;
|
|
289
|
+
contentOnStart?: boolean;
|
|
290
|
+
thumbnailsOnStart?: boolean;
|
|
291
|
+
searchOnStart?: boolean;
|
|
292
|
+
sideMenuOverBook?: boolean;
|
|
293
|
+
sideMenuOverMenu?: boolean;
|
|
294
|
+
sideMenuOverMenu2?: boolean;
|
|
295
|
+
sideMenuPosition?: "left" | "right";
|
|
296
|
+
lightBox?: boolean;
|
|
297
|
+
lightBoxOpened?: boolean;
|
|
298
|
+
lightBoxFullscreen?: boolean;
|
|
299
|
+
lightboxCloseOnClick?: boolean;
|
|
300
|
+
lightboxResetOnOpen?: boolean;
|
|
301
|
+
lightboxBackground?: string;
|
|
302
|
+
lightboxBackgroundColor?: string;
|
|
303
|
+
lightboxBackgroundPattern?: string;
|
|
304
|
+
lightboxBackgroundImage?: string;
|
|
305
|
+
lightboxStartPage?: number;
|
|
306
|
+
lightboxMarginV?: number;
|
|
307
|
+
lightboxMarginH?: number;
|
|
308
|
+
lightboxCSS?: string;
|
|
309
|
+
lightboxPreload?: boolean;
|
|
310
|
+
lightboxShowMenu?: boolean;
|
|
311
|
+
lightboxCloseOnBack?: boolean;
|
|
312
|
+
disableImageResize?: boolean;
|
|
313
|
+
pan?: number;
|
|
314
|
+
panMax?: number;
|
|
315
|
+
panMax2?: number;
|
|
316
|
+
panMin?: number;
|
|
317
|
+
panMin2?: number;
|
|
318
|
+
tilt?: number;
|
|
319
|
+
tiltMax?: number;
|
|
320
|
+
tiltMax2?: number;
|
|
321
|
+
tiltMin?: number;
|
|
322
|
+
tiltMin2?: number;
|
|
323
|
+
rotateCameraOnMouseMove?: boolean;
|
|
324
|
+
rotateCameraOnMouseDrag?: boolean;
|
|
325
|
+
lights?: boolean;
|
|
326
|
+
lightColor?: number;
|
|
327
|
+
lightPositionX?: number;
|
|
328
|
+
lightPositionZ?: number;
|
|
329
|
+
lightPositionY?: number;
|
|
330
|
+
lightIntensity?: number;
|
|
331
|
+
shadows?: boolean;
|
|
332
|
+
shadowMapSize?: number;
|
|
333
|
+
shadowOpacity?: number;
|
|
334
|
+
shadowDistance?: number;
|
|
335
|
+
pageRoughness?: number;
|
|
336
|
+
pageMetalness?: number;
|
|
337
|
+
pageHardness?: number;
|
|
338
|
+
coverHardness?: number;
|
|
339
|
+
pageSegmentsW?: number;
|
|
340
|
+
pageSegmentsH?: number;
|
|
341
|
+
pageMiddleShadowSize?: number;
|
|
342
|
+
pageMiddleShadowColorL?: string;
|
|
343
|
+
pageMiddleShadowColorR?: string;
|
|
344
|
+
antialias?: boolean;
|
|
345
|
+
/** Camera zoom/margin factor - higher values move camera further back (default: 1.35) */
|
|
346
|
+
cameraZoom?: number;
|
|
347
|
+
/** Camera vertical position offset (default: 0) */
|
|
348
|
+
cameraPositionY?: number;
|
|
349
|
+
/** Camera look-at Y position (default: 0) */
|
|
350
|
+
cameraLookAtY?: number;
|
|
351
|
+
/** Field of view in degrees (default: 45) */
|
|
352
|
+
cameraFov?: number;
|
|
353
|
+
/** Base page scale in world units - affects overall page size (default: 6) */
|
|
354
|
+
pageScale?: number;
|
|
355
|
+
preloaderText?: string;
|
|
356
|
+
fillPreloader?: FillPreloaderConfig;
|
|
357
|
+
logoImg?: string;
|
|
358
|
+
logoUrl?: string;
|
|
359
|
+
logoCSS?: string;
|
|
360
|
+
logoHideOnMobile?: boolean;
|
|
361
|
+
printMenu?: boolean;
|
|
362
|
+
downloadMenu?: boolean;
|
|
363
|
+
cover?: boolean;
|
|
364
|
+
backCover?: boolean;
|
|
365
|
+
googleAnalyticsTrackingCode?: string;
|
|
366
|
+
minimumAndroidVersion?: number;
|
|
367
|
+
linkColor?: string;
|
|
368
|
+
linkColorHover?: string;
|
|
369
|
+
linkOpacity?: number;
|
|
370
|
+
linkTarget?: string;
|
|
371
|
+
pageNumberOffset?: number;
|
|
372
|
+
flipSound?: boolean;
|
|
373
|
+
backgroundMusic?: string;
|
|
374
|
+
strings?: LocalizationStrings;
|
|
375
|
+
mobile?: MobileConfig;
|
|
376
|
+
}
|
|
377
|
+
export interface FlipbookEventMap {
|
|
378
|
+
pageFlip: {
|
|
379
|
+
page: number;
|
|
380
|
+
direction: "next" | "prev";
|
|
381
|
+
};
|
|
382
|
+
pageFlipStart: {
|
|
383
|
+
page: number;
|
|
384
|
+
direction: "next" | "prev";
|
|
385
|
+
};
|
|
386
|
+
pageFlipEnd: {
|
|
387
|
+
page: number;
|
|
388
|
+
};
|
|
389
|
+
zoomChange: {
|
|
390
|
+
zoom: number;
|
|
391
|
+
};
|
|
392
|
+
ready: void;
|
|
393
|
+
loadProgress: {
|
|
394
|
+
progress: number;
|
|
395
|
+
};
|
|
396
|
+
pageLoaded: {
|
|
397
|
+
page: number;
|
|
398
|
+
};
|
|
399
|
+
fullscreenChange: {
|
|
400
|
+
isFullscreen: boolean;
|
|
401
|
+
};
|
|
402
|
+
lightboxOpen: void;
|
|
403
|
+
lightboxClose: void;
|
|
404
|
+
soundToggle: {
|
|
405
|
+
enabled: boolean;
|
|
406
|
+
};
|
|
407
|
+
autoplayToggle: {
|
|
408
|
+
enabled: boolean;
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
export interface FlipbookInstance {
|
|
412
|
+
nextPage: () => void;
|
|
413
|
+
prevPage: () => void;
|
|
414
|
+
firstPage: () => void;
|
|
415
|
+
lastPage: () => void;
|
|
416
|
+
goToPage: (page: number) => void;
|
|
417
|
+
zoomIn: () => void;
|
|
418
|
+
zoomOut: () => void;
|
|
419
|
+
zoomTo: (zoom: number) => void;
|
|
420
|
+
getCurrentPage: () => number;
|
|
421
|
+
getNumPages: () => number;
|
|
422
|
+
getZoom: () => number;
|
|
423
|
+
isFullscreen: () => boolean;
|
|
424
|
+
toggleFullscreen: () => void;
|
|
425
|
+
toggleAutoplay: () => void;
|
|
426
|
+
toggleSound: () => void;
|
|
427
|
+
toggleThumbnails: () => void;
|
|
428
|
+
toggleTableOfContents: () => void;
|
|
429
|
+
toggleSearch: () => void;
|
|
430
|
+
openLightbox: () => void;
|
|
431
|
+
closeLightbox: () => void;
|
|
432
|
+
bookmarkPage: (page: number) => void;
|
|
433
|
+
removeBookmark: (page: number) => void;
|
|
434
|
+
getBookmarkedPages: () => number[];
|
|
435
|
+
printCurrentPage: () => void;
|
|
436
|
+
downloadCurrentPage: () => void;
|
|
437
|
+
destroy: () => void;
|
|
438
|
+
}
|
|
439
|
+
export interface FlipbookProps extends Partial<FlipbookOptions> {
|
|
440
|
+
/** Pages to display in the flipbook */
|
|
441
|
+
pages: FlipbookPage[];
|
|
442
|
+
/** Class name for the container element */
|
|
443
|
+
className?: string;
|
|
444
|
+
/** Inline styles for the container */
|
|
445
|
+
style?: React.CSSProperties;
|
|
446
|
+
/** Width of the flipbook container */
|
|
447
|
+
width?: number | string;
|
|
448
|
+
/** Height of the flipbook container */
|
|
449
|
+
height?: number | string;
|
|
450
|
+
onPageFlip?: (event: FlipbookEventMap["pageFlip"]) => void;
|
|
451
|
+
onPageFlipStart?: (event: FlipbookEventMap["pageFlipStart"]) => void;
|
|
452
|
+
onPageFlipEnd?: (event: FlipbookEventMap["pageFlipEnd"]) => void;
|
|
453
|
+
onZoomChange?: (event: FlipbookEventMap["zoomChange"]) => void;
|
|
454
|
+
onReady?: () => void;
|
|
455
|
+
onLoadProgress?: (event: FlipbookEventMap["loadProgress"]) => void;
|
|
456
|
+
onPageLoaded?: (event: FlipbookEventMap["pageLoaded"]) => void;
|
|
457
|
+
onFullscreenChange?: (event: FlipbookEventMap["fullscreenChange"]) => void;
|
|
458
|
+
onLightboxOpen?: () => void;
|
|
459
|
+
onLightboxClose?: () => void;
|
|
460
|
+
onSoundToggle?: (event: FlipbookEventMap["soundToggle"]) => void;
|
|
461
|
+
onAutoplayToggle?: (event: FlipbookEventMap["autoplayToggle"]) => void;
|
|
462
|
+
}
|
|
463
|
+
export interface UseFlipbookReturn {
|
|
464
|
+
containerRef: React.RefObject<HTMLDivElement>;
|
|
465
|
+
flipbookRef: React.RefObject<FlipbookInstance>;
|
|
466
|
+
currentPage: number;
|
|
467
|
+
numPages: number;
|
|
468
|
+
zoom: number;
|
|
469
|
+
isFullscreen: boolean;
|
|
470
|
+
isLoading: boolean;
|
|
471
|
+
isReady: boolean;
|
|
472
|
+
}
|
|
473
|
+
export interface FlipbookContextValue {
|
|
474
|
+
options: FlipbookOptions;
|
|
475
|
+
currentPage: number;
|
|
476
|
+
numPages: number;
|
|
477
|
+
zoom: number;
|
|
478
|
+
isFullscreen: boolean;
|
|
479
|
+
isLoading: boolean;
|
|
480
|
+
instance: FlipbookInstance | null;
|
|
481
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clamp a value between min and max
|
|
3
|
+
*/
|
|
4
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
5
|
+
/**
|
|
6
|
+
* Linear interpolation between two values
|
|
7
|
+
*/
|
|
8
|
+
export declare function lerp(start: number, end: number, t: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* Convert degrees to radians
|
|
11
|
+
*/
|
|
12
|
+
export declare function degToRad(degrees: number): number;
|
|
13
|
+
/**
|
|
14
|
+
* Convert radians to degrees
|
|
15
|
+
*/
|
|
16
|
+
export declare function radToDeg(radians: number): number;
|
|
17
|
+
/**
|
|
18
|
+
* Debounce a function
|
|
19
|
+
*/
|
|
20
|
+
export declare function debounce<T extends (...args: never[]) => void>(func: T, wait: number): (...args: Parameters<T>) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Throttle a function
|
|
23
|
+
*/
|
|
24
|
+
export declare function throttle<T extends (...args: unknown[]) => unknown>(func: T, limit: number): (...args: Parameters<T>) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Check if a value is a number
|
|
27
|
+
*/
|
|
28
|
+
export declare function isNumber(value: unknown): value is number;
|
|
29
|
+
/**
|
|
30
|
+
* Check if running on mobile device
|
|
31
|
+
*/
|
|
32
|
+
export declare function isMobile(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Check if touch device
|
|
35
|
+
*/
|
|
36
|
+
export declare function isTouchDevice(): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Check if WebGL is supported
|
|
39
|
+
*/
|
|
40
|
+
export declare function isWebGLSupported(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Get the aspect ratio of an image
|
|
43
|
+
*/
|
|
44
|
+
export declare function getImageAspectRatio(width: number, height: number): number;
|
|
45
|
+
/**
|
|
46
|
+
* Calculate page dimensions based on container and aspect ratio
|
|
47
|
+
*/
|
|
48
|
+
export declare function calculatePageDimensions(containerWidth: number, containerHeight: number, pageAspectRatio: number, isDoublePage?: boolean): {
|
|
49
|
+
width: number;
|
|
50
|
+
height: number;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Preload an image
|
|
54
|
+
*/
|
|
55
|
+
export declare function preloadImage(src: string): Promise<HTMLImageElement>;
|
|
56
|
+
/**
|
|
57
|
+
* Preload multiple images
|
|
58
|
+
*/
|
|
59
|
+
export declare function preloadImages(srcs: string[], onProgress?: (loaded: number, total: number) => void): Promise<HTMLImageElement[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Generate a unique ID
|
|
62
|
+
*/
|
|
63
|
+
export declare function generateId(prefix?: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* Get element offset relative to document
|
|
66
|
+
*/
|
|
67
|
+
export declare function getElementOffset(element: HTMLElement): {
|
|
68
|
+
top: number;
|
|
69
|
+
left: number;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Request fullscreen for an element
|
|
73
|
+
*/
|
|
74
|
+
export declare function requestFullscreen(element: HTMLElement): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Exit fullscreen
|
|
77
|
+
*/
|
|
78
|
+
export declare function exitFullscreen(): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Check if currently in fullscreen mode
|
|
81
|
+
*/
|
|
82
|
+
export declare function isFullscreen(): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Get fullscreen element
|
|
85
|
+
*/
|
|
86
|
+
export declare function getFullscreenElement(): Element | null;
|
|
87
|
+
/**
|
|
88
|
+
* Format page number for display
|
|
89
|
+
*/
|
|
90
|
+
export declare function formatPageNumber(page: number, totalPages: number, offset?: number): string;
|
|
91
|
+
/**
|
|
92
|
+
* Parse page number from URL hash
|
|
93
|
+
*/
|
|
94
|
+
export declare function getPageFromHash(prefix?: string): number | null;
|
|
95
|
+
/**
|
|
96
|
+
* Set page number in URL hash
|
|
97
|
+
*/
|
|
98
|
+
export declare function setPageHash(page: number, prefix?: string): void;
|
|
99
|
+
/**
|
|
100
|
+
* Clear URL hash
|
|
101
|
+
*/
|
|
102
|
+
export declare function clearHash(): void;
|
|
103
|
+
/**
|
|
104
|
+
* Local storage helpers
|
|
105
|
+
*/
|
|
106
|
+
export declare const storage: {
|
|
107
|
+
get<T>(key: string, defaultValue: T): T;
|
|
108
|
+
set<T>(key: string, value: T): void;
|
|
109
|
+
remove(key: string): void;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Easing functions for animations
|
|
113
|
+
*/
|
|
114
|
+
export declare const easing: {
|
|
115
|
+
linear: (t: number) => number;
|
|
116
|
+
easeInQuad: (t: number) => number;
|
|
117
|
+
easeOutQuad: (t: number) => number;
|
|
118
|
+
easeInOutQuad: (t: number) => number;
|
|
119
|
+
easeInCubic: (t: number) => number;
|
|
120
|
+
easeOutCubic: (t: number) => number;
|
|
121
|
+
easeInOutCubic: (t: number) => number;
|
|
122
|
+
easeInQuart: (t: number) => number;
|
|
123
|
+
easeOutQuart: (t: number) => number;
|
|
124
|
+
easeInOutQuart: (t: number) => number;
|
|
125
|
+
easeInSine: (t: number) => number;
|
|
126
|
+
easeOutSine: (t: number) => number;
|
|
127
|
+
easeInOutSine: (t: number) => number;
|
|
128
|
+
easeInExpo: (t: number) => number;
|
|
129
|
+
easeOutExpo: (t: number) => number;
|
|
130
|
+
easeInOutExpo: (t: number) => number;
|
|
131
|
+
};
|