@prose-reader/core 1.40.0 → 1.42.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/dist/index.d.ts +4366 -8
- package/dist/{prose.js → index.js} +656 -477
- package/dist/index.js.map +1 -0
- package/dist/{prose.umd.cjs → index.umd.cjs} +654 -475
- package/dist/index.umd.cjs.map +1 -0
- package/package.json +7 -7
- package/dist/cfi.d.ts +0 -74
- package/dist/constants.d.ts +0 -6
- package/dist/context.d.ts +0 -44
- package/dist/createReaderWithEnhancer.d.ts +0 -5381
- package/dist/enhancers/accessibility.d.ts +0 -4890
- package/dist/enhancers/chrome.d.ts +0 -4890
- package/dist/enhancers/fonts.d.ts +0 -4904
- package/dist/enhancers/hotkeys.d.ts +0 -4890
- package/dist/enhancers/layoutEnhancer/createMovingSafePan$.d.ts +0 -3
- package/dist/enhancers/layoutEnhancer/fixReflowable.d.ts +0 -2
- package/dist/enhancers/layoutEnhancer/layoutEnhancer.d.ts +0 -4897
- package/dist/enhancers/layoutEnhancer/types.d.ts +0 -8
- package/dist/enhancers/links.d.ts +0 -4900
- package/dist/enhancers/loadingEnhancer.d.ts +0 -4919
- package/dist/enhancers/media.d.ts +0 -4890
- package/dist/enhancers/navigation.d.ts +0 -4893
- package/dist/enhancers/pagination.d.ts +0 -5279
- package/dist/enhancers/progression.d.ts +0 -4903
- package/dist/enhancers/resources/index.d.ts +0 -4890
- package/dist/enhancers/resources/indexedDB.d.ts +0 -6
- package/dist/enhancers/resources/resourcesManager.d.ts +0 -6
- package/dist/enhancers/theme.d.ts +0 -4916
- package/dist/enhancers/types/enhancer.d.ts +0 -4894
- package/dist/enhancers/utils.d.ts +0 -4894
- package/dist/enhancers/webkit.d.ts +0 -4890
- package/dist/enhancers/zoom/elementZoomer.d.ts +0 -18
- package/dist/enhancers/zoom/index.d.ts +0 -4891
- package/dist/enhancers/zoom/types.d.ts +0 -22
- package/dist/enhancers/zoom/viewportZoomer.d.ts +0 -18
- package/dist/frames.d.ts +0 -5
- package/dist/pagination.d.ts +0 -65
- package/dist/prose.js.map +0 -1
- package/dist/prose.umd.cjs.map +0 -1
- package/dist/reader.d.ts +0 -4907
- package/dist/report.d.ts +0 -26
- package/dist/selection.d.ts +0 -6
- package/dist/settings.d.ts +0 -39
- package/dist/spine/cfiLocator.d.ts +0 -371
- package/dist/spine/createSpine.d.ts +0 -29
- package/dist/spine/eventsHelper.d.ts +0 -11
- package/dist/spine/locationResolver.d.ts +0 -697
- package/dist/spine/navigationResolver.d.ts +0 -45
- package/dist/spine/types.d.ts +0 -10
- package/dist/spineItem/commonSpineItem.d.ts +0 -171
- package/dist/spineItem/createSpineItem.d.ts +0 -181
- package/dist/spineItem/frameItem/createFrame$.d.ts +0 -1
- package/dist/spineItem/frameItem/createFrameManipulator.d.ts +0 -5
- package/dist/spineItem/frameItem/createHtmlPageFromResource.d.ts +0 -2
- package/dist/spineItem/frameItem/frameItem.d.ts +0 -46
- package/dist/spineItem/frameItem/loader.d.ts +0 -27
- package/dist/spineItem/locationResolver.d.ts +0 -23
- package/dist/spineItem/navigationResolver.d.ts +0 -13
- package/dist/spineItem/prePaginatedSpineItem.d.ts +0 -180
- package/dist/spineItem/reflowableSpineItem.d.ts +0 -179
- package/dist/spineItem/styles/getStyleForViewportDocument.d.ts +0 -1
- package/dist/spineItem/trackers.d.ts +0 -34
- package/dist/spineItem/types.d.ts +0 -19
- package/dist/spineItemManager.d.ts +0 -550
- package/dist/types/Hook.d.ts +0 -73
- package/dist/types/Spine.d.ts +0 -39
- package/dist/types/index.d.ts +0 -11
- package/dist/utils/dom.d.ts +0 -19
- package/dist/utils/layout.d.ts +0 -7
- package/dist/utils/manifest.d.ts +0 -2
- package/dist/utils/objects.d.ts +0 -6
- package/dist/utils/rxjs.d.ts +0 -4
- package/dist/viewportNavigator/manualViewportNavigator.d.ts +0 -1440
- package/dist/viewportNavigator/panViewportNavigator.d.ts +0 -215
- package/dist/viewportNavigator/scrollViewportNavigator.d.ts +0 -35
- package/dist/viewportNavigator/types.d.ts +0 -33
- package/dist/viewportNavigator/viewportNavigator.d.ts +0 -71
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Subject, BehaviorSubject, map,
|
|
2
|
-
import { withLatestFrom, distinctUntilChanged, shareReplay, tap, pairwise, filter, take, map as map$1,
|
|
1
|
+
import { takeUntil, Subject, BehaviorSubject, map, combineLatest, switchMap, merge, EMPTY, fromEvent, withLatestFrom as withLatestFrom$1, NEVER, Observable, of, scheduled, animationFrameScheduler, distinctUntilChanged as distinctUntilChanged$1, filter as filter$1, from, interval, iif, identity, take as take$1, forkJoin } from "rxjs";
|
|
2
|
+
import { withLatestFrom, distinctUntilChanged, shareReplay, tap, pairwise, switchMap as switchMap$1, filter, take, map as map$1, takeUntil as takeUntil$1, skip, debounceTime, startWith, share, exhaustMap, mergeMap, catchError, debounce, delay } from "rxjs/operators";
|
|
3
3
|
import { parseContentType, detectMimeTypeFromName } from "@prose-reader/shared";
|
|
4
|
-
const SHOULD_NOT_LAYOUT$3 = false;
|
|
5
4
|
const chromeEnhancer = (next) => (options) => {
|
|
6
5
|
const reader = next(options);
|
|
7
|
-
reader.
|
|
6
|
+
reader.context$.pipe(takeUntil(reader.$.destroy$)).subscribe(({ containerElement }) => {
|
|
7
|
+
if (!containerElement)
|
|
8
|
+
return;
|
|
8
9
|
const onScroll = () => {
|
|
9
|
-
if (reader.
|
|
10
|
-
|
|
10
|
+
if (reader.settings.getSettings().computedPageTurnMode === `controlled`) {
|
|
11
|
+
containerElement.scrollTo(0, 0);
|
|
11
12
|
}
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
-
return SHOULD_NOT_LAYOUT$3;
|
|
14
|
+
containerElement.addEventListener(`scroll`, onScroll);
|
|
15
15
|
});
|
|
16
16
|
reader.registerHook(`item.onLoad`, ({ frame }) => {
|
|
17
17
|
var _a;
|
|
@@ -51,13 +51,16 @@ const isShallowEqual = (objectA, objectB, options) => {
|
|
|
51
51
|
}
|
|
52
52
|
return true;
|
|
53
53
|
};
|
|
54
|
-
const groupBy = (list, getKey) => list.reduce(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
previous[group]
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
const groupBy = (list, getKey) => list.reduce(
|
|
55
|
+
(previous, currentItem) => {
|
|
56
|
+
const group = getKey(currentItem);
|
|
57
|
+
if (!previous[group])
|
|
58
|
+
previous[group] = [];
|
|
59
|
+
previous[group].push(currentItem);
|
|
60
|
+
return previous;
|
|
61
|
+
},
|
|
62
|
+
{}
|
|
63
|
+
);
|
|
61
64
|
const getBase64FromBlob = (data) => {
|
|
62
65
|
const reader = new FileReader();
|
|
63
66
|
return new Promise((resolve) => {
|
|
@@ -136,30 +139,35 @@ const fontsEnhancer = (next) => (options) => {
|
|
|
136
139
|
);
|
|
137
140
|
newSettings$.subscribe(settings$);
|
|
138
141
|
settings$.pipe(shouldRequireLayout, tap(applyChangeToSpineItem), takeUntil(reader.$.destroy$)).subscribe();
|
|
139
|
-
const settingsMerge$ = combineLatest([reader.settings$, settings$]).pipe(
|
|
142
|
+
const settingsMerge$ = combineLatest([reader.settings.settings$, settings$]).pipe(
|
|
140
143
|
map(([innerSettings, settings]) => ({
|
|
141
144
|
...innerSettings,
|
|
142
145
|
...settings
|
|
143
146
|
}))
|
|
144
147
|
);
|
|
148
|
+
const setSettings = (settings) => {
|
|
149
|
+
const { fontJustification: fontJustification2, fontScale: fontScale2, fontWeight: fontWeight2, lineHeight: lineHeight2, ...passthroughSettings } = settings;
|
|
150
|
+
changes$.next({ fontJustification: fontJustification2, fontScale: fontScale2, fontWeight: fontWeight2, lineHeight: lineHeight2 });
|
|
151
|
+
reader.settings.setSettings(passthroughSettings);
|
|
152
|
+
};
|
|
145
153
|
return {
|
|
146
154
|
...reader,
|
|
147
155
|
destroy: () => {
|
|
148
156
|
changes$.complete();
|
|
149
157
|
settings$.complete();
|
|
158
|
+
reader.destroy();
|
|
150
159
|
},
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
settings$: settingsMerge$
|
|
160
|
+
settings: {
|
|
161
|
+
...reader.settings,
|
|
162
|
+
setSettings,
|
|
163
|
+
settings$: settingsMerge$
|
|
164
|
+
}
|
|
157
165
|
};
|
|
158
166
|
};
|
|
159
167
|
const hotkeysEnhancer = (next) => (options) => {
|
|
160
168
|
const reader = next(options);
|
|
161
169
|
const navigateOnKey = (document2) => fromEvent(document2, "keyup").pipe(
|
|
162
|
-
withLatestFrom$1(reader.settings$),
|
|
170
|
+
withLatestFrom$1(reader.settings.settings$),
|
|
163
171
|
map(([e, { pageTurnDirection }]) => {
|
|
164
172
|
if (pageTurnDirection === "horizontal") {
|
|
165
173
|
if (e.key === `ArrowRight`) {
|
|
@@ -195,22 +203,30 @@ const hotkeysEnhancer = (next) => (options) => {
|
|
|
195
203
|
).subscribe();
|
|
196
204
|
return reader;
|
|
197
205
|
};
|
|
198
|
-
const SHOULD_NOT_LAYOUT$2 = false;
|
|
199
206
|
const createMovingSafePan$ = (reader) => {
|
|
200
207
|
let iframeOverlayForAnimationsElement;
|
|
201
|
-
reader.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
208
|
+
const updateOverlayElement$ = reader.context$.pipe(
|
|
209
|
+
switchMap$1(({ containerElement }) => {
|
|
210
|
+
if (!containerElement)
|
|
211
|
+
return NEVER;
|
|
212
|
+
return new Observable(() => {
|
|
213
|
+
iframeOverlayForAnimationsElement = containerElement.ownerDocument.createElement(`div`);
|
|
214
|
+
iframeOverlayForAnimationsElement.style.cssText = `
|
|
215
|
+
position: absolute;
|
|
216
|
+
left: 0;
|
|
217
|
+
top: 0;
|
|
218
|
+
width: 100%;
|
|
219
|
+
height: 100%;
|
|
220
|
+
visibility: hidden;
|
|
221
|
+
`;
|
|
222
|
+
containerElement.appendChild(iframeOverlayForAnimationsElement);
|
|
223
|
+
return () => {
|
|
224
|
+
iframeOverlayForAnimationsElement == null ? void 0 : iframeOverlayForAnimationsElement.remove();
|
|
225
|
+
iframeOverlayForAnimationsElement = void 0;
|
|
226
|
+
};
|
|
227
|
+
});
|
|
228
|
+
})
|
|
229
|
+
);
|
|
214
230
|
const createResetLock$ = (source) => scheduled(source, animationFrameScheduler).pipe(
|
|
215
231
|
tap(() => {
|
|
216
232
|
iframeOverlayForAnimationsElement == null ? void 0 : iframeOverlayForAnimationsElement.style.setProperty(`visibility`, `hidden`);
|
|
@@ -224,8 +240,8 @@ const createMovingSafePan$ = (reader) => {
|
|
|
224
240
|
})
|
|
225
241
|
);
|
|
226
242
|
const resetLockViewportFree$ = createResetLock$(viewportFree$).pipe(take(1));
|
|
227
|
-
const pageTurnMode$ = reader.
|
|
228
|
-
map$1(() => reader.
|
|
243
|
+
const pageTurnMode$ = reader.settings.settings$.pipe(
|
|
244
|
+
map$1(() => reader.settings.getSettings().computedPageTurnMode),
|
|
229
245
|
distinctUntilChanged()
|
|
230
246
|
);
|
|
231
247
|
const handleViewportLock$ = pageTurnMode$.pipe(
|
|
@@ -234,19 +250,22 @@ const createMovingSafePan$ = (reader) => {
|
|
|
234
250
|
),
|
|
235
251
|
takeUntil$1(reader.$.destroy$)
|
|
236
252
|
);
|
|
237
|
-
return handleViewportLock
|
|
253
|
+
return merge(updateOverlayElement$, handleViewportLock$);
|
|
238
254
|
};
|
|
239
255
|
const mapKeysTo = (keys) => {
|
|
240
256
|
return map$1((obj) => {
|
|
241
|
-
return Object.entries(obj).reduce(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
257
|
+
return Object.entries(obj).reduce(
|
|
258
|
+
(acc, [key, entry]) => {
|
|
259
|
+
if (keys.includes(key)) {
|
|
260
|
+
return {
|
|
261
|
+
...acc,
|
|
262
|
+
[key]: entry
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
return acc;
|
|
266
|
+
},
|
|
267
|
+
{}
|
|
268
|
+
);
|
|
250
269
|
});
|
|
251
270
|
};
|
|
252
271
|
const fixReflowable = (reader) => {
|
|
@@ -267,7 +286,10 @@ const fixReflowable = (reader) => {
|
|
|
267
286
|
}
|
|
268
287
|
});
|
|
269
288
|
};
|
|
270
|
-
|
|
289
|
+
function isDefined(arg) {
|
|
290
|
+
return arg !== null && arg !== void 0;
|
|
291
|
+
}
|
|
292
|
+
const SHOULD_NOT_LAYOUT = false;
|
|
271
293
|
const layoutEnhancer = (next) => (options) => {
|
|
272
294
|
const { pageHorizontalMargin = 24, pageVerticalMargin = 24 } = options;
|
|
273
295
|
const reader = next(options);
|
|
@@ -282,7 +304,7 @@ const layoutEnhancer = (next) => (options) => {
|
|
|
282
304
|
void frame.getBoundingClientRect().left;
|
|
283
305
|
hasRedrawn = true;
|
|
284
306
|
}
|
|
285
|
-
return SHOULD_NOT_LAYOUT
|
|
307
|
+
return SHOULD_NOT_LAYOUT;
|
|
286
308
|
});
|
|
287
309
|
});
|
|
288
310
|
reader.registerHook(`item.onLayoutBeforeMeasurement`, ({ frame, minimumWidth, item, isImageType }) => {
|
|
@@ -327,10 +349,17 @@ const layoutEnhancer = (next) => (options) => {
|
|
|
327
349
|
fixReflowable(reader);
|
|
328
350
|
let observer;
|
|
329
351
|
if (options.layoutAutoResize === `container`) {
|
|
330
|
-
|
|
331
|
-
|
|
352
|
+
reader.context$.pipe(
|
|
353
|
+
map$1((state) => state.containerElement),
|
|
354
|
+
filter(isDefined),
|
|
355
|
+
distinctUntilChanged(),
|
|
356
|
+
takeUntil$1(reader.$.destroy$)
|
|
357
|
+
).subscribe((container) => {
|
|
358
|
+
observer = new ResizeObserver(() => {
|
|
359
|
+
reader == null ? void 0 : reader.layout();
|
|
360
|
+
});
|
|
361
|
+
observer.observe(container);
|
|
332
362
|
});
|
|
333
|
-
observer.observe(options.containerElement);
|
|
334
363
|
}
|
|
335
364
|
const movingSafePan$ = createMovingSafePan$(reader);
|
|
336
365
|
movingSafePan$.subscribe();
|
|
@@ -343,27 +372,32 @@ const layoutEnhancer = (next) => (options) => {
|
|
|
343
372
|
}),
|
|
344
373
|
takeUntil$1(reader.$.destroy$)
|
|
345
374
|
).subscribe();
|
|
375
|
+
const settings$ = combineLatest([reader.settings.settings$, settingsSubject$.asObservable()]).pipe(
|
|
376
|
+
map$1(([innerSettings, settings]) => ({
|
|
377
|
+
...innerSettings,
|
|
378
|
+
...settings
|
|
379
|
+
}))
|
|
380
|
+
);
|
|
381
|
+
const setSettings = ({ pageVerticalMargin: pageVerticalMargin2, pageHorizontalMargin: pageHorizontalMargin2, ...rest }) => {
|
|
382
|
+
if (pageHorizontalMargin2 !== void 0 || pageVerticalMargin2 !== void 0) {
|
|
383
|
+
settingsSubject$.next({
|
|
384
|
+
pageHorizontalMargin: pageHorizontalMargin2 ?? settingsSubject$.value.pageHorizontalMargin,
|
|
385
|
+
pageVerticalMargin: pageVerticalMargin2 ?? settingsSubject$.value.pageVerticalMargin
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
reader.settings.setSettings(rest);
|
|
389
|
+
};
|
|
346
390
|
return {
|
|
347
391
|
...reader,
|
|
348
392
|
destroy: () => {
|
|
349
393
|
reader.destroy();
|
|
350
394
|
observer == null ? void 0 : observer.disconnect();
|
|
351
395
|
},
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
reader.setSettings(rest);
|
|
360
|
-
},
|
|
361
|
-
settings$: combineLatest([reader.settings$, settingsSubject$.asObservable()]).pipe(
|
|
362
|
-
map$1(([innerSettings, settings]) => ({
|
|
363
|
-
...innerSettings,
|
|
364
|
-
...settings
|
|
365
|
-
}))
|
|
366
|
-
)
|
|
396
|
+
settings: {
|
|
397
|
+
...reader.settings,
|
|
398
|
+
setSettings,
|
|
399
|
+
settings$
|
|
400
|
+
}
|
|
367
401
|
};
|
|
368
402
|
};
|
|
369
403
|
const ROOT_NAMESPACE = `@prose-reader/core`;
|
|
@@ -455,13 +489,15 @@ const linksEnhancer = (next) => (options) => {
|
|
|
455
489
|
const handleNavigationForClick = (element) => {
|
|
456
490
|
var _a;
|
|
457
491
|
if (!element.href)
|
|
458
|
-
return;
|
|
492
|
+
return false;
|
|
459
493
|
const hrefUrl = new URL(element.href);
|
|
460
494
|
const hrefWithoutAnchor = `${hrefUrl.origin}${hrefUrl.pathname}`;
|
|
461
495
|
const hasExistingSpineItem = (_a = reader.context.getManifest()) == null ? void 0 : _a.spineItems.some((item) => item.href === hrefWithoutAnchor);
|
|
462
496
|
if (hasExistingSpineItem) {
|
|
463
497
|
reader.goToUrl(hrefUrl);
|
|
498
|
+
return true;
|
|
464
499
|
}
|
|
500
|
+
return false;
|
|
465
501
|
};
|
|
466
502
|
reader.registerHook(`item.onLoad`, ({ frame }) => {
|
|
467
503
|
if (frame.contentDocument) {
|
|
@@ -470,8 +506,8 @@ const linksEnhancer = (next) => (options) => {
|
|
|
470
506
|
if (e.target && `style` in e.target && `ELEMENT_NODE` in e.target) {
|
|
471
507
|
Report.warn(`prevented click on`, element, e);
|
|
472
508
|
e.preventDefault();
|
|
473
|
-
handleNavigationForClick(element);
|
|
474
|
-
subject.next({ event: `linkClicked`, data: element });
|
|
509
|
+
const isNavigable = handleNavigationForClick(element);
|
|
510
|
+
subject.next({ event: `linkClicked`, data: element, isNavigable });
|
|
475
511
|
}
|
|
476
512
|
})
|
|
477
513
|
);
|
|
@@ -485,8 +521,7 @@ const linksEnhancer = (next) => (options) => {
|
|
|
485
521
|
}
|
|
486
522
|
};
|
|
487
523
|
};
|
|
488
|
-
const
|
|
489
|
-
const reader = next(options);
|
|
524
|
+
const createNavigator = (reader) => {
|
|
490
525
|
const goToNextSpineItem = () => {
|
|
491
526
|
var _a;
|
|
492
527
|
const focusedSpineItemIndex = reader.getFocusedSpineItemIndex() || 0;
|
|
@@ -506,14 +541,19 @@ const navigationEnhancer = (next) => (options) => {
|
|
|
506
541
|
}
|
|
507
542
|
};
|
|
508
543
|
return {
|
|
509
|
-
|
|
544
|
+
goToNextSpineItem,
|
|
545
|
+
goToPreviousSpineItem,
|
|
510
546
|
goToLeftSpineItem: () => {
|
|
547
|
+
if (reader.settings.getSettings().computedPageTurnDirection === "vertical")
|
|
548
|
+
return;
|
|
511
549
|
if (reader.context.isRTL()) {
|
|
512
550
|
return goToNextSpineItem();
|
|
513
551
|
}
|
|
514
552
|
return goToPreviousSpineItem();
|
|
515
553
|
},
|
|
516
554
|
goToRightSpineItem: () => {
|
|
555
|
+
if (reader.settings.getSettings().computedPageTurnDirection === "vertical")
|
|
556
|
+
return;
|
|
517
557
|
if (reader.context.isRTL()) {
|
|
518
558
|
return goToPreviousSpineItem();
|
|
519
559
|
}
|
|
@@ -521,15 +561,44 @@ const navigationEnhancer = (next) => (options) => {
|
|
|
521
561
|
}
|
|
522
562
|
};
|
|
523
563
|
};
|
|
564
|
+
const createState = (reader) => {
|
|
565
|
+
return reader.pagination.paginationInfo$.pipe(
|
|
566
|
+
withLatestFrom$1(reader.context.$.manifest$, reader.settings.settings$),
|
|
567
|
+
map(([paginationInfo, manifest, { computedPageTurnDirection }]) => {
|
|
568
|
+
const numberOfSpineItems = (manifest == null ? void 0 : manifest.spineItems.length) ?? 0;
|
|
569
|
+
const isAtAbsoluteBeginning = paginationInfo.beginSpineItemIndex === 0 && paginationInfo.beginPageIndexInSpineItem === 0;
|
|
570
|
+
const isAtAbsoluteEnd = paginationInfo.endPageIndexInSpineItem === paginationInfo.endNumberOfPagesInSpineItem - 1 && paginationInfo.endSpineItemIndex === Math.max(numberOfSpineItems - 1, 0);
|
|
571
|
+
return {
|
|
572
|
+
canGoTopSpineItem: computedPageTurnDirection === "vertical" && !isAtAbsoluteBeginning,
|
|
573
|
+
canGoBottomSpineItem: computedPageTurnDirection === "vertical" && !isAtAbsoluteEnd,
|
|
574
|
+
canGoLeftSpineItem: computedPageTurnDirection !== "vertical" && ((manifest == null ? void 0 : manifest.readingDirection) === "ltr" && !isAtAbsoluteBeginning || (manifest == null ? void 0 : manifest.readingDirection) === "rtl" && !isAtAbsoluteEnd),
|
|
575
|
+
canGoRightSpineItem: computedPageTurnDirection !== "vertical" && ((manifest == null ? void 0 : manifest.readingDirection) === "ltr" && !isAtAbsoluteEnd || (manifest == null ? void 0 : manifest.readingDirection) === "rtl" && !isAtAbsoluteBeginning)
|
|
576
|
+
};
|
|
577
|
+
}),
|
|
578
|
+
distinctUntilChanged$1(isShallowEqual)
|
|
579
|
+
);
|
|
580
|
+
};
|
|
581
|
+
const navigationEnhancer = (next) => (options) => {
|
|
582
|
+
const reader = next(options);
|
|
583
|
+
const state$ = createState(reader);
|
|
584
|
+
const navigator2 = createNavigator(reader);
|
|
585
|
+
return {
|
|
586
|
+
...reader,
|
|
587
|
+
navigation: {
|
|
588
|
+
...navigator2,
|
|
589
|
+
state$
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
};
|
|
524
593
|
const NAMESPACE$6 = `pagination`;
|
|
525
594
|
const createPagination = ({ context }) => {
|
|
526
595
|
const paginationSubject$ = new BehaviorSubject({
|
|
527
|
-
|
|
528
|
-
|
|
596
|
+
beginPageIndexInSpineItem: void 0,
|
|
597
|
+
beginNumberOfPagesInSpineItem: 0,
|
|
529
598
|
beginCfi: void 0,
|
|
530
599
|
beginSpineItemIndex: void 0,
|
|
531
|
-
|
|
532
|
-
|
|
600
|
+
endPageIndexInSpineItem: void 0,
|
|
601
|
+
endNumberOfPagesInSpineItem: 0,
|
|
533
602
|
endCfi: void 0,
|
|
534
603
|
endSpineItemIndex: void 0
|
|
535
604
|
});
|
|
@@ -556,12 +625,12 @@ const createPagination = ({ context }) => {
|
|
|
556
625
|
const beginInfo = getInfoForUpdate(begin);
|
|
557
626
|
const endInfo = getInfoForUpdate(end);
|
|
558
627
|
const newValues = {
|
|
559
|
-
|
|
560
|
-
|
|
628
|
+
beginPageIndexInSpineItem: beginInfo.pageIndex,
|
|
629
|
+
beginNumberOfPagesInSpineItem: beginInfo.numberOfPages,
|
|
561
630
|
beginCfi: beginInfo.cfi,
|
|
562
631
|
beginSpineItemIndex: begin.spineItemIndex,
|
|
563
|
-
|
|
564
|
-
|
|
632
|
+
endPageIndexInSpineItem: endInfo.pageIndex,
|
|
633
|
+
endNumberOfPagesInSpineItem: endInfo.numberOfPages,
|
|
565
634
|
endCfi: endInfo.cfi,
|
|
566
635
|
endSpineItemIndex: end.spineItemIndex
|
|
567
636
|
};
|
|
@@ -572,18 +641,19 @@ const createPagination = ({ context }) => {
|
|
|
572
641
|
},
|
|
573
642
|
{ disable: true }
|
|
574
643
|
);
|
|
575
|
-
const
|
|
576
|
-
const
|
|
644
|
+
const getPaginationInfo = () => paginationSubject$.value;
|
|
645
|
+
const paginationInfo$ = paginationSubject$.pipe(
|
|
646
|
+
distinctUntilChanged$1(isShallowEqual),
|
|
647
|
+
filter$1(({ beginPageIndexInSpineItem }) => beginPageIndexInSpineItem !== void 0)
|
|
648
|
+
);
|
|
577
649
|
const destroy = () => {
|
|
578
650
|
paginationSubject$.complete();
|
|
579
651
|
};
|
|
580
652
|
return {
|
|
581
653
|
destroy,
|
|
582
654
|
updateBeginAndEnd,
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
info$
|
|
586
|
-
}
|
|
655
|
+
getPaginationInfo,
|
|
656
|
+
paginationInfo$
|
|
587
657
|
};
|
|
588
658
|
};
|
|
589
659
|
const getItemOffsetFromPageIndex = (pageWidth, pageIndex, itemWidth) => {
|
|
@@ -614,15 +684,10 @@ const paginationEnhancer = (next) => (options) => {
|
|
|
614
684
|
};
|
|
615
685
|
const mapPaginationInfoToExtendedInfo = (paginationInfo) => {
|
|
616
686
|
const context = reader.context;
|
|
617
|
-
const manifest = context.getManifest();
|
|
618
|
-
const numberOfSpineItems = (manifest == null ? void 0 : manifest.spineItems.length) ?? 0;
|
|
619
687
|
const beginItem = paginationInfo.beginSpineItemIndex !== void 0 ? reader.getSpineItem(paginationInfo.beginSpineItemIndex) : void 0;
|
|
620
688
|
const endItem = paginationInfo.endSpineItemIndex !== void 0 ? reader.getSpineItem(paginationInfo.endSpineItemIndex) : void 0;
|
|
621
|
-
const isAtAbsoluteBeginning = paginationInfo.beginSpineItemIndex === 0 && paginationInfo.beginPageIndex === 0;
|
|
622
|
-
const isAtAbsoluteEnd = paginationInfo.endPageIndex === paginationInfo.endNumberOfPages - 1 && paginationInfo.endSpineItemIndex === Math.max(numberOfSpineItems - 1, 0);
|
|
623
689
|
return {
|
|
624
|
-
|
|
625
|
-
beginNumberOfPagesInChapter: paginationInfo.beginNumberOfPages,
|
|
690
|
+
...paginationInfo,
|
|
626
691
|
beginChapterInfo: beginItem ? chaptersInfo[beginItem.item.id] : void 0,
|
|
627
692
|
// chapterIndex: number;
|
|
628
693
|
// pages: number;
|
|
@@ -634,15 +699,9 @@ const paginationEnhancer = (next) => (options) => {
|
|
|
634
699
|
// domIndex: number;
|
|
635
700
|
// charOffset: number;
|
|
636
701
|
// serializeString?: string;
|
|
637
|
-
beginSpineItemIndex: paginationInfo.beginSpineItemIndex,
|
|
638
|
-
beginCfi: paginationInfo.beginCfi,
|
|
639
702
|
beginSpineItemReadingDirection: beginItem == null ? void 0 : beginItem.getReadingDirection(),
|
|
640
703
|
endChapterInfo: endItem ? chaptersInfo[endItem.item.id] : void 0,
|
|
641
|
-
endPageIndexInChapter: paginationInfo.endPageIndex,
|
|
642
|
-
endNumberOfPagesInChapter: paginationInfo.endNumberOfPages,
|
|
643
|
-
endSpineItemIndex: paginationInfo.endSpineItemIndex,
|
|
644
704
|
endSpineItemReadingDirection: endItem == null ? void 0 : endItem.getReadingDirection(),
|
|
645
|
-
endCfi: paginationInfo.endCfi,
|
|
646
705
|
// spineItemReadingDirection: focusedSpineItem?.getReadingDirection(),
|
|
647
706
|
/**
|
|
648
707
|
* This percentage is based of the weight (kb) of every items and the number of pages.
|
|
@@ -653,23 +712,21 @@ const paginationEnhancer = (next) => (options) => {
|
|
|
653
712
|
percentageEstimateOfBook: endItem ? reader.progression.getPercentageEstimate(
|
|
654
713
|
context,
|
|
655
714
|
paginationInfo.endSpineItemIndex ?? 0,
|
|
656
|
-
paginationInfo.
|
|
657
|
-
paginationInfo.
|
|
715
|
+
paginationInfo.endNumberOfPagesInSpineItem,
|
|
716
|
+
paginationInfo.endPageIndexInSpineItem || 0,
|
|
658
717
|
reader.getCurrentViewportPosition(),
|
|
659
718
|
endItem
|
|
660
719
|
) : 0,
|
|
661
|
-
isUsingSpread: context.
|
|
720
|
+
isUsingSpread: context.isUsingSpreadMode() ?? false
|
|
662
721
|
// hasNextChapter: (reader.spine.spineItemIndex || 0) < (manifest.readingOrder.length - 1),
|
|
663
722
|
// hasPreviousChapter: (reader.spine.spineItemIndex || 0) < (manifest.readingOrder.length - 1),
|
|
664
723
|
// numberOfSpineItems: context.getManifest()?.readingOrder.length,
|
|
665
|
-
canGoLeft: (manifest == null ? void 0 : manifest.readingDirection) === "ltr" && !isAtAbsoluteBeginning || (manifest == null ? void 0 : manifest.readingDirection) === "rtl" && !isAtAbsoluteEnd,
|
|
666
|
-
canGoRight: (manifest == null ? void 0 : manifest.readingDirection) === "ltr" && !isAtAbsoluteEnd || (manifest == null ? void 0 : manifest.readingDirection) === "rtl" && !isAtAbsoluteBeginning
|
|
667
724
|
};
|
|
668
725
|
};
|
|
669
726
|
const getSpineItemNumberOfPages = (spineItem) => {
|
|
670
727
|
const writingMode = spineItem.spineItemFrame.getWritingMode();
|
|
671
728
|
const { width, height } = spineItem.getElementDimensions();
|
|
672
|
-
const settings = reader.
|
|
729
|
+
const settings = reader.settings.getSettings();
|
|
673
730
|
if (settings.pageTurnDirection === `vertical` && settings.pageTurnMode === `scrollable`) {
|
|
674
731
|
return 1;
|
|
675
732
|
}
|
|
@@ -689,7 +746,7 @@ const paginationEnhancer = (next) => (options) => {
|
|
|
689
746
|
),
|
|
690
747
|
takeUntil$1(reader.$.destroy$)
|
|
691
748
|
).subscribe();
|
|
692
|
-
const innerPaginationExtendedInfo$ = reader.pagination$.pipe(
|
|
749
|
+
const innerPaginationExtendedInfo$ = reader.pagination.paginationInfo$.pipe(
|
|
693
750
|
map$1((info) => ({
|
|
694
751
|
...info,
|
|
695
752
|
...mapPaginationInfoToExtendedInfo(info)
|
|
@@ -698,7 +755,7 @@ const paginationEnhancer = (next) => (options) => {
|
|
|
698
755
|
);
|
|
699
756
|
const totalPages$ = reader.$.layout$.pipe(
|
|
700
757
|
debounceTime(10, animationFrameScheduler),
|
|
701
|
-
withLatestFrom(reader.pagination$),
|
|
758
|
+
withLatestFrom(reader.pagination.paginationInfo$),
|
|
702
759
|
map$1(() => {
|
|
703
760
|
const numberOfPagesPerItems = getNumberOfPagesPerItems();
|
|
704
761
|
return {
|
|
@@ -715,19 +772,25 @@ const paginationEnhancer = (next) => (options) => {
|
|
|
715
772
|
numberOfTotalPages: 0
|
|
716
773
|
})
|
|
717
774
|
);
|
|
718
|
-
const
|
|
775
|
+
const paginationInfo$ = combineLatest([
|
|
776
|
+
innerPaginationExtendedInfo$,
|
|
777
|
+
totalPages$
|
|
778
|
+
]).pipe(
|
|
719
779
|
map$1(([pageInfo, totalPageInfo]) => ({
|
|
720
780
|
...pageInfo,
|
|
721
781
|
...totalPageInfo,
|
|
722
|
-
beginAbsolutePageIndex: totalPageInfo.numberOfPagesPerItems.slice(0, pageInfo.beginSpineItemIndex).reduce((acc, numberOfPagesForItem) => acc + numberOfPagesForItem, pageInfo.
|
|
723
|
-
endAbsolutePageIndex: totalPageInfo.numberOfPagesPerItems.slice(0, pageInfo.endSpineItemIndex).reduce((acc, numberOfPagesForItem) => acc + numberOfPagesForItem, pageInfo.
|
|
782
|
+
beginAbsolutePageIndex: totalPageInfo.numberOfPagesPerItems.slice(0, pageInfo.beginSpineItemIndex).reduce((acc, numberOfPagesForItem) => acc + numberOfPagesForItem, pageInfo.beginPageIndexInSpineItem ?? 0),
|
|
783
|
+
endAbsolutePageIndex: totalPageInfo.numberOfPagesPerItems.slice(0, pageInfo.endSpineItemIndex).reduce((acc, numberOfPagesForItem) => acc + numberOfPagesForItem, pageInfo.endPageIndexInSpineItem ?? 0)
|
|
724
784
|
})),
|
|
725
785
|
shareReplay(1),
|
|
726
786
|
takeUntil$1(reader.$.destroy$)
|
|
727
787
|
);
|
|
728
788
|
return {
|
|
729
789
|
...reader,
|
|
730
|
-
pagination
|
|
790
|
+
pagination: {
|
|
791
|
+
...reader.pagination,
|
|
792
|
+
paginationInfo$
|
|
793
|
+
}
|
|
731
794
|
};
|
|
732
795
|
};
|
|
733
796
|
const buildChapterInfoFromSpineItem = (manifest, item) => {
|
|
@@ -848,7 +911,6 @@ const themeEnhancer = (next) => (options) => {
|
|
|
848
911
|
}
|
|
849
912
|
};
|
|
850
913
|
};
|
|
851
|
-
const SHOULD_NOT_LAYOUT = false;
|
|
852
914
|
const createElementZoomer = (reader) => {
|
|
853
915
|
const isZooming$ = new BehaviorSubject(false);
|
|
854
916
|
let imageMagnifierContainer;
|
|
@@ -861,7 +923,8 @@ const createElementZoomer = (reader) => {
|
|
|
861
923
|
imgLastPosition = { x: 0, y: 0 };
|
|
862
924
|
baseScale = 1;
|
|
863
925
|
lastUserScale = 1;
|
|
864
|
-
reader.
|
|
926
|
+
const container = reader.context.getState().containerElement;
|
|
927
|
+
if (container) {
|
|
865
928
|
imageMagnifierContainer = container.ownerDocument.createElement(`div`);
|
|
866
929
|
imageMagnifierContainer.style.cssText = `
|
|
867
930
|
top: 0;
|
|
@@ -872,6 +935,7 @@ const createElementZoomer = (reader) => {
|
|
|
872
935
|
background: black;
|
|
873
936
|
width: 100%;
|
|
874
937
|
height: 100%;
|
|
938
|
+
user-select: none;
|
|
875
939
|
`;
|
|
876
940
|
const clonedImgElement = imgElement.cloneNode();
|
|
877
941
|
clonedImgElement.src = imgElement.src;
|
|
@@ -881,8 +945,7 @@ const createElementZoomer = (reader) => {
|
|
|
881
945
|
clonedImgElement.style.setProperty(`pointer-events`, `none`);
|
|
882
946
|
imageMagnifierContainer.appendChild(clonedImgElement);
|
|
883
947
|
container.appendChild(imageMagnifierContainer);
|
|
884
|
-
|
|
885
|
-
});
|
|
948
|
+
}
|
|
886
949
|
scale(1.2);
|
|
887
950
|
setCurrentScaleAsBase();
|
|
888
951
|
};
|
|
@@ -905,14 +968,14 @@ const createElementZoomer = (reader) => {
|
|
|
905
968
|
const move = (delta, { isFirst, isLast }) => {
|
|
906
969
|
const imgElement = imageMagnifierContainer == null ? void 0 : imageMagnifierContainer.querySelector(`img`);
|
|
907
970
|
if (isFirst) {
|
|
908
|
-
movingLastDelta =
|
|
971
|
+
movingLastDelta = delta;
|
|
909
972
|
}
|
|
910
973
|
if (delta) {
|
|
911
|
-
const
|
|
912
|
-
const
|
|
974
|
+
const newOffsetX = delta.x - ((movingLastDelta == null ? void 0 : movingLastDelta.x) || 0);
|
|
975
|
+
const newOffsetY = delta.y - ((movingLastDelta == null ? void 0 : movingLastDelta.y) || 0);
|
|
913
976
|
imgLastPosition = {
|
|
914
|
-
x: imgLastPosition.x +
|
|
915
|
-
y: imgLastPosition.y +
|
|
977
|
+
x: imgLastPosition.x + newOffsetX,
|
|
978
|
+
y: imgLastPosition.y + newOffsetY
|
|
916
979
|
};
|
|
917
980
|
imgElement == null ? void 0 : imgElement.style.setProperty(
|
|
918
981
|
`transform`,
|
|
@@ -926,11 +989,8 @@ const createElementZoomer = (reader) => {
|
|
|
926
989
|
};
|
|
927
990
|
const exit = () => {
|
|
928
991
|
lastUserScale = 1;
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
imageMagnifierContainer = void 0;
|
|
932
|
-
return SHOULD_NOT_LAYOUT;
|
|
933
|
-
});
|
|
992
|
+
imageMagnifierContainer == null ? void 0 : imageMagnifierContainer.remove();
|
|
993
|
+
imageMagnifierContainer = void 0;
|
|
934
994
|
isZooming$.next(false);
|
|
935
995
|
};
|
|
936
996
|
const _isZooming = () => isZooming$.value;
|
|
@@ -974,7 +1034,10 @@ const createViewportZoomer = (reader) => {
|
|
|
974
1034
|
};
|
|
975
1035
|
const enter = () => {
|
|
976
1036
|
reset();
|
|
977
|
-
reader.spine.
|
|
1037
|
+
const spineElement = reader.spine.getElement();
|
|
1038
|
+
if (spineElement) {
|
|
1039
|
+
spineElement.style.transformOrigin = `0 0`;
|
|
1040
|
+
}
|
|
978
1041
|
isZooming$.next(true);
|
|
979
1042
|
scale(1);
|
|
980
1043
|
setCurrentScaleAsBase();
|
|
@@ -983,23 +1046,27 @@ const createViewportZoomer = (reader) => {
|
|
|
983
1046
|
baseScale = lastUserScale;
|
|
984
1047
|
};
|
|
985
1048
|
const scale = (userScale) => {
|
|
1049
|
+
const spineElement = reader.spine.getElement();
|
|
1050
|
+
const viewportElement = reader.viewportNavigator.getElement();
|
|
1051
|
+
if (!spineElement || !viewportElement)
|
|
1052
|
+
return;
|
|
986
1053
|
const roundedScale = Math.ceil((userScale < 1 ? baseScale - (1 - userScale) : baseScale + (userScale - 1)) * 100) / 100;
|
|
987
1054
|
const newScale = Math.max(roundedScale, 1);
|
|
988
|
-
const currentScale =
|
|
989
|
-
const currentScrollTop =
|
|
990
|
-
|
|
991
|
-
|
|
1055
|
+
const currentScale = spineElement.getBoundingClientRect().width / spineElement.offsetWidth;
|
|
1056
|
+
const currentScrollTop = viewportElement.scrollTop;
|
|
1057
|
+
spineElement.style.transform = `scale(${newScale})`;
|
|
1058
|
+
viewportElement.scrollLeft = getNewScaledOffset({
|
|
992
1059
|
newScale,
|
|
993
1060
|
oldScale: currentScale,
|
|
994
|
-
pageSize:
|
|
995
|
-
screenSize:
|
|
996
|
-
scrollOffset:
|
|
1061
|
+
pageSize: viewportElement.clientWidth,
|
|
1062
|
+
screenSize: spineElement.offsetWidth,
|
|
1063
|
+
scrollOffset: viewportElement.scrollLeft
|
|
997
1064
|
});
|
|
998
|
-
|
|
1065
|
+
viewportElement.scrollTop = getNewScaledOffset({
|
|
999
1066
|
newScale,
|
|
1000
1067
|
oldScale: currentScale,
|
|
1001
|
-
pageSize:
|
|
1002
|
-
screenSize:
|
|
1068
|
+
pageSize: viewportElement.clientHeight,
|
|
1069
|
+
screenSize: spineElement.offsetHeight,
|
|
1003
1070
|
scrollOffset: currentScrollTop
|
|
1004
1071
|
});
|
|
1005
1072
|
lastUserScale = newScale;
|
|
@@ -1031,7 +1098,7 @@ const zoomEnhancer = (next) => (options) => {
|
|
|
1031
1098
|
const elementZoomer = createElementZoomer(reader);
|
|
1032
1099
|
const viewportZoomer = createViewportZoomer(reader);
|
|
1033
1100
|
const currentZoomerSubject$ = new BehaviorSubject(void 0);
|
|
1034
|
-
const isUsingScrollableViewport = () => reader.
|
|
1101
|
+
const isUsingScrollableViewport = () => reader.settings.getSettings().computedPageTurnMode === `scrollable`;
|
|
1035
1102
|
const enter = (imgElement) => {
|
|
1036
1103
|
var _a;
|
|
1037
1104
|
(_a = currentZoomerSubject$ == null ? void 0 : currentZoomerSubject$.value) == null ? void 0 : _a.exit();
|
|
@@ -1097,83 +1164,44 @@ const zoomEnhancer = (next) => (options) => {
|
|
|
1097
1164
|
}
|
|
1098
1165
|
};
|
|
1099
1166
|
};
|
|
1100
|
-
const
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
numberOfAdjacentSpineItemToPreLoad: 0,
|
|
1114
|
-
...initialSettings
|
|
1115
|
-
};
|
|
1116
|
-
updateComputedSettings(void 0, mergedSettings, false);
|
|
1117
|
-
const settingsSubject$ = new BehaviorSubject(mergedSettings);
|
|
1118
|
-
const setSettings = (newSettings, options) => {
|
|
1119
|
-
if (Object.keys(newSettings).length === 0)
|
|
1120
|
-
return;
|
|
1121
|
-
const newMergedSettings = { ...settingsSubject$.value, ...newSettings };
|
|
1122
|
-
updateComputedSettings(options.manifest, newMergedSettings, options.hasVerticalWritingSubject);
|
|
1123
|
-
settingsSubject$.next(newMergedSettings);
|
|
1124
|
-
};
|
|
1125
|
-
const recompute = (options) => {
|
|
1126
|
-
const newMergedSettings = { ...settingsSubject$.value };
|
|
1127
|
-
updateComputedSettings(options.manifest, newMergedSettings, options.hasVerticalWritingSubject);
|
|
1128
|
-
settingsSubject$.next(newMergedSettings);
|
|
1129
|
-
};
|
|
1130
|
-
const destroy = () => {
|
|
1131
|
-
settingsSubject$.complete();
|
|
1132
|
-
};
|
|
1133
|
-
return {
|
|
1134
|
-
getSettings: () => settingsSubject$.value,
|
|
1135
|
-
setSettings,
|
|
1136
|
-
recompute,
|
|
1137
|
-
destroy,
|
|
1138
|
-
$: {
|
|
1139
|
-
settings$: settingsSubject$.asObservable().pipe(distinctUntilChanged(isShallowEqual))
|
|
1140
|
-
}
|
|
1141
|
-
};
|
|
1142
|
-
};
|
|
1143
|
-
const areAllItemsPrePaginated$1 = (manifest) => !(manifest == null ? void 0 : manifest.spineItems.some((item) => item.renditionLayout === `reflowable`));
|
|
1144
|
-
const updateComputedSettings = (newManifest, settings, hasVerticalWriting) => {
|
|
1145
|
-
settings.computedPageTurnDirection = settings.pageTurnDirection;
|
|
1146
|
-
settings.computedPageTurnAnimation = settings.pageTurnAnimation;
|
|
1147
|
-
settings.computedPageTurnMode = `controlled`;
|
|
1148
|
-
if ((newManifest == null ? void 0 : newManifest.renditionFlow) === `scrolled-continuous`) {
|
|
1149
|
-
settings.computedPageTurnMode = `scrollable`;
|
|
1150
|
-
settings.computedPageTurnDirection = `vertical`;
|
|
1151
|
-
} else if (newManifest && settings.pageTurnMode === `scrollable` && (newManifest.renditionLayout !== `pre-paginated` || !areAllItemsPrePaginated$1(newManifest))) {
|
|
1152
|
-
Report.warn(`pageTurnMode ${settings.pageTurnMode} incompatible with current book, switching back to default`);
|
|
1153
|
-
settings.computedPageTurnAnimation = `none`;
|
|
1154
|
-
settings.computedPageTurnMode = `controlled`;
|
|
1155
|
-
} else if (settings.pageTurnMode === `scrollable`) {
|
|
1156
|
-
settings.computedPageTurnMode = `scrollable`;
|
|
1157
|
-
settings.computedPageTurnDirection = `vertical`;
|
|
1158
|
-
}
|
|
1159
|
-
if (hasVerticalWriting && settings.computedPageTurnAnimation === `slide`) {
|
|
1160
|
-
Report.warn(
|
|
1161
|
-
`pageTurnAnimation ${settings.computedPageTurnAnimation} incompatible with current book, switching back to default`
|
|
1162
|
-
);
|
|
1163
|
-
settings.computedPageTurnAnimation = `none`;
|
|
1164
|
-
}
|
|
1165
|
-
if (settings.computedPageTurnMode === `scrollable`) {
|
|
1166
|
-
settings.computedPageTurnAnimationDuration = 0;
|
|
1167
|
-
settings.computedPageTurnAnimation = `none`;
|
|
1168
|
-
} else {
|
|
1169
|
-
settings.computedPageTurnAnimationDuration = settings.pageTurnAnimationDuration !== void 0 ? settings.pageTurnAnimationDuration : 300;
|
|
1167
|
+
const isUsingSpreadMode = ({
|
|
1168
|
+
manifest,
|
|
1169
|
+
visibleAreaRect,
|
|
1170
|
+
forceSinglePageMode
|
|
1171
|
+
}) => {
|
|
1172
|
+
const { height, width } = visibleAreaRect;
|
|
1173
|
+
const isLandscape = width > height;
|
|
1174
|
+
if (forceSinglePageMode)
|
|
1175
|
+
return false;
|
|
1176
|
+
if ((manifest == null ? void 0 : manifest.renditionFlow) === `scrolled-continuous`)
|
|
1177
|
+
return false;
|
|
1178
|
+
if (!isLandscape && (manifest == null ? void 0 : manifest.renditionSpread) === `portrait`) {
|
|
1179
|
+
return true;
|
|
1170
1180
|
}
|
|
1181
|
+
return isLandscape && ((manifest == null ? void 0 : manifest.renditionSpread) === void 0 || (manifest == null ? void 0 : manifest.renditionSpread) === `auto` || (manifest == null ? void 0 : manifest.renditionSpread) === `landscape` || (manifest == null ? void 0 : manifest.renditionSpread) === `both`);
|
|
1171
1182
|
};
|
|
1172
|
-
const
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
const
|
|
1176
|
-
|
|
1183
|
+
const isFullyPrePaginated = (manifest) => (manifest == null ? void 0 : manifest.renditionLayout) === "pre-paginated" || (manifest == null ? void 0 : manifest.spineItems.every((item) => item.renditionLayout === "pre-paginated"));
|
|
1184
|
+
const createContext = (settings) => {
|
|
1185
|
+
const stateSubject = new BehaviorSubject({});
|
|
1186
|
+
const manifest$ = stateSubject.pipe(
|
|
1187
|
+
map$1((state) => state.manifest),
|
|
1188
|
+
filter(isDefined),
|
|
1189
|
+
distinctUntilChanged()
|
|
1190
|
+
);
|
|
1191
|
+
const containerElement$ = stateSubject.pipe(
|
|
1192
|
+
map$1((state) => state.containerElement),
|
|
1193
|
+
filter(isDefined),
|
|
1194
|
+
distinctUntilChanged()
|
|
1195
|
+
);
|
|
1196
|
+
const hasVerticalWriting$ = stateSubject.pipe(
|
|
1197
|
+
map$1((state) => state.hasVerticalWriting),
|
|
1198
|
+
filter(isDefined),
|
|
1199
|
+
distinctUntilChanged()
|
|
1200
|
+
);
|
|
1201
|
+
const isUsingSpreadMode$ = stateSubject.pipe(
|
|
1202
|
+
map$1((state) => state.isUsingSpreadMode),
|
|
1203
|
+
distinctUntilChanged()
|
|
1204
|
+
);
|
|
1177
1205
|
const visibleAreaRect = {
|
|
1178
1206
|
width: 0,
|
|
1179
1207
|
height: 0,
|
|
@@ -1183,82 +1211,113 @@ const createContext = (initialSettings) => {
|
|
|
1183
1211
|
const marginTop = 0;
|
|
1184
1212
|
const marginBottom = 0;
|
|
1185
1213
|
const destroy$ = new Subject();
|
|
1186
|
-
const
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
if (settings.getSettings().forceSinglePageMode)
|
|
1191
|
-
return false;
|
|
1192
|
-
if ((manifest == null ? void 0 : manifest.renditionFlow) === `scrolled-continuous`)
|
|
1193
|
-
return false;
|
|
1194
|
-
if (!isLandscape && (manifest == null ? void 0 : manifest.renditionSpread) === `portrait`) {
|
|
1195
|
-
return true;
|
|
1214
|
+
const setState = (newState) => {
|
|
1215
|
+
const newCompleteState = { ...stateSubject.getValue(), ...newState };
|
|
1216
|
+
if (!isShallowEqual(newCompleteState, stateSubject.getValue())) {
|
|
1217
|
+
stateSubject.next(newCompleteState);
|
|
1196
1218
|
}
|
|
1197
|
-
return isLandscape && ((manifest == null ? void 0 : manifest.renditionSpread) === void 0 || (manifest == null ? void 0 : manifest.renditionSpread) === `auto` || (manifest == null ? void 0 : manifest.renditionSpread) === `landscape` || (manifest == null ? void 0 : manifest.renditionSpread) === `both`);
|
|
1198
1219
|
};
|
|
1199
1220
|
const load = (newManifest, newLoadOptions) => {
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1221
|
+
setState({
|
|
1222
|
+
manifest: newManifest,
|
|
1223
|
+
...newLoadOptions,
|
|
1224
|
+
isFullyPrePaginated: isFullyPrePaginated(newManifest),
|
|
1225
|
+
isUsingSpreadMode: isUsingSpreadMode({
|
|
1226
|
+
manifest: newManifest,
|
|
1227
|
+
visibleAreaRect,
|
|
1228
|
+
forceSinglePageMode: settings.getSettings().forceSinglePageMode
|
|
1229
|
+
})
|
|
1230
|
+
});
|
|
1204
1231
|
};
|
|
1205
1232
|
const isRTL = () => {
|
|
1206
|
-
|
|
1233
|
+
var _a;
|
|
1234
|
+
return ((_a = stateSubject.getValue().manifest) == null ? void 0 : _a.readingDirection) === `rtl`;
|
|
1207
1235
|
};
|
|
1208
|
-
const setHasVerticalWriting = () =>
|
|
1209
|
-
|
|
1210
|
-
|
|
1236
|
+
const setHasVerticalWriting = (value) => setState({
|
|
1237
|
+
hasVerticalWriting: value
|
|
1238
|
+
});
|
|
1239
|
+
const recomputeSettings$ = merge(hasVerticalWriting$, manifest$);
|
|
1240
|
+
recomputeSettings$.pipe(
|
|
1241
|
+
withLatestFrom(hasVerticalWriting$, manifest$),
|
|
1242
|
+
tap(([, hasVerticalWriting, manifest]) => {
|
|
1243
|
+
settings.recompute({ hasVerticalWriting, manifest });
|
|
1244
|
+
}),
|
|
1245
|
+
takeUntil$1(destroy$)
|
|
1246
|
+
).subscribe();
|
|
1247
|
+
settings.$.settings$.pipe(
|
|
1248
|
+
map$1(({ forceSinglePageMode }) => forceSinglePageMode),
|
|
1211
1249
|
distinctUntilChanged(),
|
|
1212
|
-
|
|
1213
|
-
|
|
1250
|
+
withLatestFrom(manifest$),
|
|
1251
|
+
tap(([forceSinglePageMode, manifest]) => {
|
|
1252
|
+
setState({
|
|
1253
|
+
isUsingSpreadMode: isUsingSpreadMode({
|
|
1254
|
+
manifest,
|
|
1255
|
+
visibleAreaRect,
|
|
1256
|
+
forceSinglePageMode
|
|
1257
|
+
})
|
|
1258
|
+
});
|
|
1214
1259
|
}),
|
|
1215
1260
|
takeUntil$1(destroy$)
|
|
1216
1261
|
).subscribe();
|
|
1217
1262
|
const destroy = () => {
|
|
1218
|
-
|
|
1219
|
-
loadSubject$.complete();
|
|
1263
|
+
stateSubject.complete();
|
|
1220
1264
|
destroy$.next();
|
|
1221
1265
|
destroy$.complete();
|
|
1222
|
-
hasVerticalWritingSubject$.complete();
|
|
1223
1266
|
};
|
|
1224
1267
|
return {
|
|
1225
1268
|
load,
|
|
1226
1269
|
isRTL,
|
|
1227
|
-
areAllItemsPrePaginated: () =>
|
|
1270
|
+
areAllItemsPrePaginated: () => {
|
|
1271
|
+
var _a;
|
|
1272
|
+
return areAllItemsPrePaginated$1((_a = stateSubject.getValue()) == null ? void 0 : _a.manifest);
|
|
1273
|
+
},
|
|
1228
1274
|
destroy,
|
|
1229
|
-
getLoadOptions: () => loadOptions,
|
|
1230
1275
|
getCalculatedInnerMargin: () => 0,
|
|
1231
1276
|
getVisibleAreaRect: () => visibleAreaRect,
|
|
1232
|
-
|
|
1277
|
+
isUsingSpreadMode: () => stateSubject.getValue().isUsingSpreadMode,
|
|
1233
1278
|
setHasVerticalWriting,
|
|
1234
1279
|
setVisibleAreaRect: ({ height, width, x, y }) => {
|
|
1235
1280
|
visibleAreaRect.width = width;
|
|
1236
1281
|
visibleAreaRect.height = height - marginTop - marginBottom;
|
|
1237
1282
|
visibleAreaRect.x = x;
|
|
1238
1283
|
visibleAreaRect.y = y;
|
|
1284
|
+
const manifest = stateSubject.getValue().manifest;
|
|
1285
|
+
if (manifest) {
|
|
1286
|
+
setState({
|
|
1287
|
+
isUsingSpreadMode: isUsingSpreadMode({
|
|
1288
|
+
manifest,
|
|
1289
|
+
visibleAreaRect,
|
|
1290
|
+
forceSinglePageMode: settings.getSettings().forceSinglePageMode
|
|
1291
|
+
})
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
},
|
|
1295
|
+
getState: () => stateSubject.getValue(),
|
|
1296
|
+
getManifest: () => {
|
|
1297
|
+
var _a;
|
|
1298
|
+
return (_a = stateSubject.getValue()) == null ? void 0 : _a.manifest;
|
|
1299
|
+
},
|
|
1300
|
+
getReadingDirection: () => {
|
|
1301
|
+
var _a, _b;
|
|
1302
|
+
return (_b = (_a = stateSubject.getValue()) == null ? void 0 : _a.manifest) == null ? void 0 : _b.readingDirection;
|
|
1239
1303
|
},
|
|
1240
|
-
getManifest: () => manifest,
|
|
1241
|
-
getReadingDirection: () => manifest == null ? void 0 : manifest.readingDirection,
|
|
1242
1304
|
getPageSize: () => {
|
|
1243
1305
|
return {
|
|
1244
|
-
width:
|
|
1306
|
+
width: stateSubject.getValue().isUsingSpreadMode ? visibleAreaRect.width / 2 : visibleAreaRect.width,
|
|
1245
1307
|
height: visibleAreaRect.height
|
|
1246
1308
|
};
|
|
1247
1309
|
},
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
manifest
|
|
1252
|
-
}),
|
|
1310
|
+
containerElement$,
|
|
1311
|
+
isUsingSpreadMode$,
|
|
1312
|
+
hasVerticalWriting$,
|
|
1253
1313
|
$: {
|
|
1254
|
-
|
|
1314
|
+
manifest$,
|
|
1255
1315
|
destroy$: destroy$.asObservable(),
|
|
1256
|
-
|
|
1257
|
-
load$: loadSubject$.asObservable()
|
|
1316
|
+
state$: stateSubject.asObservable()
|
|
1258
1317
|
}
|
|
1259
1318
|
};
|
|
1260
1319
|
};
|
|
1261
|
-
const areAllItemsPrePaginated = (manifest) => !(manifest == null ? void 0 : manifest.spineItems.some((item) => item.renditionLayout === `reflowable`));
|
|
1320
|
+
const areAllItemsPrePaginated$1 = (manifest) => !(manifest == null ? void 0 : manifest.spineItems.some((item) => item.renditionLayout === `reflowable`));
|
|
1262
1321
|
const __UNSAFE_REFERENCE_ORIGINAL_IFRAME_EVENT_KEY = `__UNSAFE_REFERENCE_ORIGINAL_IFRAME_EVENT`;
|
|
1263
1322
|
const ITEM_EXTENSION_VALID_FOR_FRAME_SRC = [`.xhtml`, `.html`, `.htm`];
|
|
1264
1323
|
const HTML_PREFIX$1 = `prose-reader`;
|
|
@@ -1375,7 +1434,8 @@ const createLoader = ({
|
|
|
1375
1434
|
fetchResource,
|
|
1376
1435
|
hooks$,
|
|
1377
1436
|
context,
|
|
1378
|
-
viewportState
|
|
1437
|
+
viewportState$,
|
|
1438
|
+
settings
|
|
1379
1439
|
}) => {
|
|
1380
1440
|
const destroySubject$ = new Subject();
|
|
1381
1441
|
const loadSubject$ = new Subject();
|
|
@@ -1464,7 +1524,7 @@ const createLoader = ({
|
|
|
1464
1524
|
if ((frame == null ? void 0 : frame.contentDocument) && body) {
|
|
1465
1525
|
computedStyleAfterLoad = (_b = frame == null ? void 0 : frame.contentWindow) == null ? void 0 : _b.getComputedStyle(body);
|
|
1466
1526
|
}
|
|
1467
|
-
if (
|
|
1527
|
+
if (settings.getSettings().computedPageTurnMode !== `scrollable`) {
|
|
1468
1528
|
frame.setAttribute(`tab-index`, `0`);
|
|
1469
1529
|
}
|
|
1470
1530
|
const manipulableFrame = createFrameManipulator(frame);
|
|
@@ -1533,7 +1593,8 @@ const createFrameItem = ({
|
|
|
1533
1593
|
fetchResource,
|
|
1534
1594
|
context,
|
|
1535
1595
|
hooks$,
|
|
1536
|
-
viewportState
|
|
1596
|
+
viewportState$,
|
|
1597
|
+
settings
|
|
1537
1598
|
}) => {
|
|
1538
1599
|
const destroySubject$ = new Subject();
|
|
1539
1600
|
const {
|
|
@@ -1542,7 +1603,7 @@ const createFrameItem = ({
|
|
|
1542
1603
|
unload,
|
|
1543
1604
|
destroy: loaderDestroy,
|
|
1544
1605
|
getComputedStyleAfterLoad
|
|
1545
|
-
} = createLoader({ context, hooks$, item, parent, fetchResource, viewportState
|
|
1606
|
+
} = createLoader({ context, hooks$, item, parent, fetchResource, viewportState$, settings });
|
|
1546
1607
|
let isLoadedSync = false;
|
|
1547
1608
|
let isReadySync = false;
|
|
1548
1609
|
isLoaded$.subscribe({
|
|
@@ -1630,7 +1691,7 @@ const createFrameItem = ({
|
|
|
1630
1691
|
if (frame) {
|
|
1631
1692
|
frame.style.width = `${size.width}px`;
|
|
1632
1693
|
frame.style.height = `${size.height}px`;
|
|
1633
|
-
if (
|
|
1694
|
+
if (settings.getSettings().computedPageTurnMode !== `scrollable`) {
|
|
1634
1695
|
frame.setAttribute(`tab-index`, `0`);
|
|
1635
1696
|
}
|
|
1636
1697
|
}
|
|
@@ -1895,9 +1956,12 @@ const pointerEvents = [
|
|
|
1895
1956
|
`pointermove`,
|
|
1896
1957
|
`pointerout`,
|
|
1897
1958
|
`pointerover`,
|
|
1898
|
-
`pointerup
|
|
1959
|
+
`pointerup`,
|
|
1960
|
+
`touchstart`,
|
|
1961
|
+
`touchend`
|
|
1899
1962
|
];
|
|
1900
1963
|
const mouseEvents = [
|
|
1964
|
+
`click`,
|
|
1901
1965
|
`mousedown`,
|
|
1902
1966
|
`mouseup`,
|
|
1903
1967
|
`mouseenter`,
|
|
@@ -1911,9 +1975,10 @@ const createCommonSpineItem = ({
|
|
|
1911
1975
|
item,
|
|
1912
1976
|
context,
|
|
1913
1977
|
parentElement,
|
|
1914
|
-
iframeEventBridgeElement
|
|
1978
|
+
iframeEventBridgeElement$,
|
|
1915
1979
|
hooks$,
|
|
1916
|
-
viewportState
|
|
1980
|
+
viewportState$,
|
|
1981
|
+
settings
|
|
1917
1982
|
}) => {
|
|
1918
1983
|
var _a;
|
|
1919
1984
|
const destroySubject$ = new Subject();
|
|
@@ -1921,14 +1986,15 @@ const createCommonSpineItem = ({
|
|
|
1921
1986
|
const overlayElement = createOverlayElement(parentElement, item);
|
|
1922
1987
|
const fingerTracker = createFingerTracker();
|
|
1923
1988
|
const selectionTracker = createSelectionTracker();
|
|
1924
|
-
const frameHooks = createFrameHooks(iframeEventBridgeElement
|
|
1989
|
+
const frameHooks = createFrameHooks(iframeEventBridgeElement$, fingerTracker, selectionTracker);
|
|
1925
1990
|
const spineItemFrame = createFrameItem({
|
|
1926
1991
|
parent: containerElement,
|
|
1927
1992
|
item,
|
|
1928
1993
|
context,
|
|
1929
|
-
fetchResource: (_a = context.
|
|
1994
|
+
fetchResource: (_a = context.getState()) == null ? void 0 : _a.fetchResource,
|
|
1930
1995
|
hooks$: hooks$.asObservable().pipe(map$1((hooks) => [...hooks, ...frameHooks])),
|
|
1931
|
-
viewportState
|
|
1996
|
+
viewportState$,
|
|
1997
|
+
settings
|
|
1932
1998
|
});
|
|
1933
1999
|
containerElement.appendChild(overlayElement);
|
|
1934
2000
|
parentElement.appendChild(containerElement);
|
|
@@ -2053,10 +2119,10 @@ const createCommonSpineItem = ({
|
|
|
2053
2119
|
};
|
|
2054
2120
|
};
|
|
2055
2121
|
const getResource = async () => {
|
|
2056
|
-
const
|
|
2122
|
+
const fetchResource = context.getState().fetchResource;
|
|
2057
2123
|
const lastFetch = (_) => {
|
|
2058
|
-
if (
|
|
2059
|
-
return
|
|
2124
|
+
if (fetchResource) {
|
|
2125
|
+
return fetchResource(item);
|
|
2060
2126
|
}
|
|
2061
2127
|
return fetch(item.href);
|
|
2062
2128
|
};
|
|
@@ -2192,7 +2258,7 @@ const createOverlayElement = (containerElement, item) => {
|
|
|
2192
2258
|
`;
|
|
2193
2259
|
return element;
|
|
2194
2260
|
};
|
|
2195
|
-
const createFrameHooks = (iframeEventBridgeElement
|
|
2261
|
+
const createFrameHooks = (iframeEventBridgeElement$, fingerTracker, selectionTracker) => {
|
|
2196
2262
|
return [
|
|
2197
2263
|
{
|
|
2198
2264
|
name: `item.onLoad`,
|
|
@@ -2200,6 +2266,7 @@ const createFrameHooks = (iframeEventBridgeElement, fingerTracker, selectionTrac
|
|
|
2200
2266
|
const unregister = passthroughEvents.map((event) => {
|
|
2201
2267
|
var _a;
|
|
2202
2268
|
const listener = (e) => {
|
|
2269
|
+
var _a2;
|
|
2203
2270
|
let convertedEvent = e;
|
|
2204
2271
|
if (isPointerEvent(e)) {
|
|
2205
2272
|
convertedEvent = new PointerEvent(e.type, e);
|
|
@@ -2209,7 +2276,7 @@ const createFrameHooks = (iframeEventBridgeElement, fingerTracker, selectionTrac
|
|
|
2209
2276
|
}
|
|
2210
2277
|
if (convertedEvent !== e) {
|
|
2211
2278
|
attachOriginalFrameEventToDocumentEvent(convertedEvent, e);
|
|
2212
|
-
iframeEventBridgeElement.dispatchEvent(convertedEvent);
|
|
2279
|
+
(_a2 = iframeEventBridgeElement$.getValue()) == null ? void 0 : _a2.dispatchEvent(convertedEvent);
|
|
2213
2280
|
}
|
|
2214
2281
|
};
|
|
2215
2282
|
(_a = frame.contentDocument) == null ? void 0 : _a.addEventListener(event, listener);
|
|
@@ -2239,17 +2306,19 @@ const createPrePaginatedSpineItem = ({
|
|
|
2239
2306
|
item,
|
|
2240
2307
|
context,
|
|
2241
2308
|
containerElement,
|
|
2242
|
-
iframeEventBridgeElement
|
|
2309
|
+
iframeEventBridgeElement$,
|
|
2243
2310
|
hooks$,
|
|
2244
|
-
viewportState
|
|
2311
|
+
viewportState$,
|
|
2312
|
+
settings
|
|
2245
2313
|
}) => {
|
|
2246
2314
|
const commonSpineItem = createCommonSpineItem({
|
|
2247
2315
|
context,
|
|
2248
2316
|
item,
|
|
2249
2317
|
parentElement: containerElement,
|
|
2250
|
-
iframeEventBridgeElement
|
|
2318
|
+
iframeEventBridgeElement$,
|
|
2251
2319
|
hooks$,
|
|
2252
|
-
viewportState
|
|
2320
|
+
viewportState$,
|
|
2321
|
+
settings
|
|
2253
2322
|
});
|
|
2254
2323
|
const spineItemFrame = commonSpineItem.spineItemFrame;
|
|
2255
2324
|
const layout = ({
|
|
@@ -2268,7 +2337,7 @@ const createPrePaginatedSpineItem = ({
|
|
|
2268
2337
|
const cssLink = buildDocumentStyle(
|
|
2269
2338
|
{
|
|
2270
2339
|
...commonSpineItem.getDimensionsForPaginatedContent(),
|
|
2271
|
-
enableTouch:
|
|
2340
|
+
enableTouch: settings.getSettings().computedPageTurnMode !== `scrollable`,
|
|
2272
2341
|
spreadPosition
|
|
2273
2342
|
},
|
|
2274
2343
|
viewportDimensions
|
|
@@ -2411,17 +2480,19 @@ const createReflowableSpineItem = ({
|
|
|
2411
2480
|
item,
|
|
2412
2481
|
context,
|
|
2413
2482
|
containerElement,
|
|
2414
|
-
iframeEventBridgeElement
|
|
2483
|
+
iframeEventBridgeElement$,
|
|
2415
2484
|
hooks$,
|
|
2416
|
-
viewportState
|
|
2485
|
+
viewportState$,
|
|
2486
|
+
settings
|
|
2417
2487
|
}) => {
|
|
2418
2488
|
const commonSpineItem = createCommonSpineItem({
|
|
2419
2489
|
context,
|
|
2420
2490
|
item,
|
|
2421
2491
|
parentElement: containerElement,
|
|
2422
|
-
iframeEventBridgeElement
|
|
2492
|
+
iframeEventBridgeElement$,
|
|
2423
2493
|
hooks$,
|
|
2424
|
-
viewportState
|
|
2494
|
+
viewportState$,
|
|
2495
|
+
settings
|
|
2425
2496
|
});
|
|
2426
2497
|
const spineItemFrame = commonSpineItem.spineItemFrame;
|
|
2427
2498
|
let latestContentHeightWhenLoaded;
|
|
@@ -2460,7 +2531,7 @@ const createReflowableSpineItem = ({
|
|
|
2460
2531
|
} else {
|
|
2461
2532
|
const frameStyle = commonSpineItem.isImageType() ? buildStyleForReflowableImageOnly({
|
|
2462
2533
|
isScrollable: ((_g = context.getManifest()) == null ? void 0 : _g.renditionFlow) === `scrolled-continuous`,
|
|
2463
|
-
enableTouch:
|
|
2534
|
+
enableTouch: settings.getSettings().computedPageTurnMode !== `scrollable`
|
|
2464
2535
|
}) : buildStyleWithMultiColumn(
|
|
2465
2536
|
commonSpineItem.getDimensionsForReflowableContent(spineItemFrame.isUsingVerticalWriting(), minimumWidth)
|
|
2466
2537
|
);
|
|
@@ -2685,36 +2756,39 @@ const createSpineItem = ({
|
|
|
2685
2756
|
item,
|
|
2686
2757
|
context,
|
|
2687
2758
|
containerElement,
|
|
2688
|
-
iframeEventBridgeElement
|
|
2759
|
+
iframeEventBridgeElement$,
|
|
2689
2760
|
hooks$,
|
|
2690
|
-
viewportState
|
|
2761
|
+
viewportState$,
|
|
2762
|
+
settings
|
|
2691
2763
|
}) => {
|
|
2692
2764
|
if (item.renditionLayout === `pre-paginated`) {
|
|
2693
2765
|
return createPrePaginatedSpineItem({
|
|
2694
2766
|
item,
|
|
2695
2767
|
context,
|
|
2696
2768
|
containerElement,
|
|
2697
|
-
iframeEventBridgeElement
|
|
2769
|
+
iframeEventBridgeElement$,
|
|
2698
2770
|
hooks$,
|
|
2699
|
-
viewportState
|
|
2771
|
+
viewportState$,
|
|
2772
|
+
settings
|
|
2700
2773
|
});
|
|
2701
2774
|
}
|
|
2702
2775
|
return createReflowableSpineItem({
|
|
2703
2776
|
item,
|
|
2704
2777
|
context,
|
|
2705
2778
|
containerElement,
|
|
2706
|
-
iframeEventBridgeElement
|
|
2779
|
+
iframeEventBridgeElement$,
|
|
2707
2780
|
hooks$,
|
|
2708
|
-
viewportState
|
|
2781
|
+
viewportState$,
|
|
2782
|
+
settings
|
|
2709
2783
|
});
|
|
2710
2784
|
};
|
|
2711
2785
|
const createEventsHelper = ({
|
|
2712
|
-
iframeEventBridgeElement
|
|
2786
|
+
iframeEventBridgeElement$,
|
|
2713
2787
|
locator
|
|
2714
2788
|
}) => {
|
|
2715
2789
|
const normalizeEventForViewport = (event) => {
|
|
2716
2790
|
var _a;
|
|
2717
|
-
const eventIsComingFromBridge = event.target === iframeEventBridgeElement;
|
|
2791
|
+
const eventIsComingFromBridge = event.target === iframeEventBridgeElement$.getValue();
|
|
2718
2792
|
const iframeOriginalEvent = getOriginalFrameEventFromDocumentEvent(event);
|
|
2719
2793
|
const originalFrame = (_a = iframeOriginalEvent == null ? void 0 : iframeOriginalEvent.view) == null ? void 0 : _a.frameElement;
|
|
2720
2794
|
if (!eventIsComingFromBridge || !iframeOriginalEvent || !originalFrame)
|
|
@@ -3662,11 +3736,12 @@ const createSelection = (selection, item) => {
|
|
|
3662
3736
|
};
|
|
3663
3737
|
};
|
|
3664
3738
|
const report = Report.namespace(`spine`);
|
|
3739
|
+
const noopElement$1 = document.createElement("div");
|
|
3665
3740
|
const createSpine = ({
|
|
3666
|
-
|
|
3741
|
+
element$,
|
|
3667
3742
|
context,
|
|
3668
3743
|
pagination,
|
|
3669
|
-
iframeEventBridgeElement
|
|
3744
|
+
iframeEventBridgeElement$,
|
|
3670
3745
|
spineItemManager,
|
|
3671
3746
|
hooks$,
|
|
3672
3747
|
spineItemLocator,
|
|
@@ -3675,31 +3750,32 @@ const createSpine = ({
|
|
|
3675
3750
|
navigation$,
|
|
3676
3751
|
navigationAdjusted$,
|
|
3677
3752
|
currentNavigationPosition$,
|
|
3678
|
-
viewportState
|
|
3753
|
+
viewportState$,
|
|
3754
|
+
settings
|
|
3679
3755
|
}) => {
|
|
3680
3756
|
const spineItems$ = new Subject();
|
|
3681
3757
|
const itemsBeforeDestroySubject$ = new Subject();
|
|
3682
3758
|
const subject = new Subject();
|
|
3683
|
-
const containerElement =
|
|
3759
|
+
const containerElement$ = new BehaviorSubject(noopElement$1);
|
|
3684
3760
|
const eventsHelper = createEventsHelper({
|
|
3685
3761
|
context,
|
|
3686
3762
|
spineItemManager,
|
|
3687
|
-
iframeEventBridgeElement
|
|
3763
|
+
iframeEventBridgeElement$,
|
|
3688
3764
|
locator: spineLocator
|
|
3689
3765
|
});
|
|
3690
3766
|
let selectionSubscription;
|
|
3691
|
-
const reload = () => {
|
|
3692
|
-
var _a;
|
|
3767
|
+
const reload = (manifest) => {
|
|
3693
3768
|
itemsBeforeDestroySubject$.next();
|
|
3694
3769
|
spineItemManager.destroyItems();
|
|
3695
|
-
|
|
3770
|
+
manifest.spineItems.map((resource) => {
|
|
3696
3771
|
const spineItem = createSpineItem({
|
|
3697
3772
|
item: resource,
|
|
3698
|
-
containerElement,
|
|
3699
|
-
iframeEventBridgeElement
|
|
3773
|
+
containerElement: containerElement$.getValue(),
|
|
3774
|
+
iframeEventBridgeElement$,
|
|
3700
3775
|
context,
|
|
3701
3776
|
hooks$,
|
|
3702
|
-
viewportState
|
|
3777
|
+
viewportState$,
|
|
3778
|
+
settings
|
|
3703
3779
|
});
|
|
3704
3780
|
spineItemManager.add(spineItem);
|
|
3705
3781
|
});
|
|
@@ -3718,7 +3794,7 @@ const createSpine = ({
|
|
|
3718
3794
|
var _a;
|
|
3719
3795
|
(_a = spineItemManager.get(id)) == null ? void 0 : _a.manipulateSpineItem(cb);
|
|
3720
3796
|
};
|
|
3721
|
-
context.$.
|
|
3797
|
+
context.$.manifest$.pipe(tap(reload), takeUntil$1(context.$.destroy$)).subscribe();
|
|
3722
3798
|
const waitForViewportFree$ = viewportState$.pipe(
|
|
3723
3799
|
filter((v) => v === `free`),
|
|
3724
3800
|
take(1)
|
|
@@ -3733,10 +3809,10 @@ const createSpine = ({
|
|
|
3733
3809
|
const spineItemsFromPosition = spineLocator.getSpineItemsFromReadingOrderPosition(position);
|
|
3734
3810
|
const beginSpineItem = spineItemsFromPosition ? spineItemManager.get(spineItemsFromPosition.begin) : void 0;
|
|
3735
3811
|
const endSpineItem = spineItemsFromPosition ? spineItemManager.get(spineItemsFromPosition.end) : void 0;
|
|
3736
|
-
const beginLastCfi = pagination.
|
|
3737
|
-
const endLastCfi = pagination.
|
|
3738
|
-
const shouldUpdateBeginCfi = pagination.
|
|
3739
|
-
const shouldUpdateEndCfi = pagination.
|
|
3812
|
+
const beginLastCfi = pagination.getPaginationInfo().beginCfi;
|
|
3813
|
+
const endLastCfi = pagination.getPaginationInfo().endCfi;
|
|
3814
|
+
const shouldUpdateBeginCfi = pagination.getPaginationInfo().beginSpineItemIndex !== (spineItemsFromPosition == null ? void 0 : spineItemsFromPosition.begin) || beginLastCfi === void 0 || (beginLastCfi == null ? void 0 : beginLastCfi.startsWith(`epubcfi(/0`));
|
|
3815
|
+
const shouldUpdateEndCfi = pagination.getPaginationInfo().endSpineItemIndex !== (spineItemsFromPosition == null ? void 0 : spineItemsFromPosition.end) || endLastCfi === void 0 || (endLastCfi == null ? void 0 : endLastCfi.startsWith(`epubcfi(/0`));
|
|
3740
3816
|
if (beginSpineItem && endSpineItem && spineItemsFromPosition) {
|
|
3741
3817
|
const beginPosition = spineLocator.getSpineItemPositionFromSpinePosition(
|
|
3742
3818
|
spineItemsFromPosition.beginPosition,
|
|
@@ -3795,16 +3871,10 @@ const createSpine = ({
|
|
|
3795
3871
|
selectionTracker$.pipe(
|
|
3796
3872
|
filter(({ event: event2 }) => event2 === `selectstart`),
|
|
3797
3873
|
switchMap$1(
|
|
3798
|
-
(
|
|
3874
|
+
() => fingerTracker$.pipe(
|
|
3799
3875
|
filter(({ event: event2 }) => event2 === `fingermove`),
|
|
3800
3876
|
debounce(() => interval(1e3)),
|
|
3801
|
-
takeUntil$1(
|
|
3802
|
-
fingerTracker$.pipe(
|
|
3803
|
-
filter(({ event: event2 }) => event2 === `fingerout`),
|
|
3804
|
-
tap(() => {
|
|
3805
|
-
})
|
|
3806
|
-
)
|
|
3807
|
-
),
|
|
3877
|
+
takeUntil$1(fingerTracker$.pipe(filter(({ event: event2 }) => event2 === `fingerout`))),
|
|
3808
3878
|
tap(({ data }) => {
|
|
3809
3879
|
})
|
|
3810
3880
|
)
|
|
@@ -3862,7 +3932,7 @@ const createSpine = ({
|
|
|
3862
3932
|
*
|
|
3863
3933
|
* The cfi is later adjusted with heavy dom lookup once the viewport is free.
|
|
3864
3934
|
*/
|
|
3865
|
-
cfi: (lastExpectedNavigation == null ? void 0 : lastExpectedNavigation.type) === `navigate-from-cfi` && spineItemToFocus === beginSpineItem ? lastExpectedNavigation.data : data.triggeredBy === `adjust` &&
|
|
3935
|
+
cfi: (lastExpectedNavigation == null ? void 0 : lastExpectedNavigation.type) === `navigate-from-cfi` && spineItemToFocus === beginSpineItem ? lastExpectedNavigation.data : data.triggeredBy === `adjust` && settings.getSettings().computedPageTurnMode === `controlled` ? pagination.getPaginationInfo().beginCfi : beginItemIndex !== pagination.getPaginationInfo().beginSpineItemIndex ? cfiLocator.getRootCfi(beginSpineItem) : (
|
|
3866
3936
|
/* @todo check ? */
|
|
3867
3937
|
cfiLocator.getRootCfi(beginSpineItem)
|
|
3868
3938
|
),
|
|
@@ -3874,7 +3944,7 @@ const createSpine = ({
|
|
|
3874
3944
|
spineItem: endSpineItem,
|
|
3875
3945
|
spineItemIndex: endItemIndex,
|
|
3876
3946
|
pageIndex: endPageIndex,
|
|
3877
|
-
cfi: (lastExpectedNavigation == null ? void 0 : lastExpectedNavigation.type) === `navigate-from-cfi` && spineItemToFocus === endSpineItem ? lastExpectedNavigation.data : data.triggeredBy === `adjust` &&
|
|
3947
|
+
cfi: (lastExpectedNavigation == null ? void 0 : lastExpectedNavigation.type) === `navigate-from-cfi` && spineItemToFocus === endSpineItem ? lastExpectedNavigation.data : data.triggeredBy === `adjust` && settings.getSettings().computedPageTurnMode === `controlled` ? pagination.getPaginationInfo().endCfi : endItemIndex !== pagination.getPaginationInfo().endSpineItemIndex ? cfiLocator.getRootCfi(endSpineItem) : (
|
|
3878
3948
|
/* @todo check ? */
|
|
3879
3949
|
cfiLocator.getRootCfi(endSpineItem)
|
|
3880
3950
|
),
|
|
@@ -3940,8 +4010,13 @@ const createSpine = ({
|
|
|
3940
4010
|
}),
|
|
3941
4011
|
takeUntil$1(context.$.destroy$)
|
|
3942
4012
|
).subscribe();
|
|
4013
|
+
const elementSub = element$.pipe().subscribe((element) => {
|
|
4014
|
+
const containerElement = createContainerElement(element.ownerDocument);
|
|
4015
|
+
containerElement$.next(containerElement);
|
|
4016
|
+
});
|
|
3943
4017
|
return {
|
|
3944
|
-
element
|
|
4018
|
+
element$: containerElement$,
|
|
4019
|
+
getElement: () => containerElement$.getValue(),
|
|
3945
4020
|
locator: spineLocator,
|
|
3946
4021
|
spineItemLocator,
|
|
3947
4022
|
cfiLocator,
|
|
@@ -3949,13 +4024,14 @@ const createSpine = ({
|
|
|
3949
4024
|
manipulateSpineItems,
|
|
3950
4025
|
manipulateSpineItem,
|
|
3951
4026
|
destroy: () => {
|
|
4027
|
+
elementSub.unsubscribe();
|
|
3952
4028
|
spineItems$.complete();
|
|
3953
4029
|
itemsBeforeDestroySubject$.next();
|
|
3954
4030
|
itemsBeforeDestroySubject$.complete();
|
|
3955
4031
|
subject.complete();
|
|
3956
4032
|
spineItemManager.destroy();
|
|
3957
4033
|
selectionSubscription == null ? void 0 : selectionSubscription.unsubscribe();
|
|
3958
|
-
containerElement.remove();
|
|
4034
|
+
containerElement$.getValue().remove();
|
|
3959
4035
|
},
|
|
3960
4036
|
adjustPagination,
|
|
3961
4037
|
isSelecting: () => {
|
|
@@ -3974,31 +4050,17 @@ const createSpine = ({
|
|
|
3974
4050
|
}
|
|
3975
4051
|
};
|
|
3976
4052
|
};
|
|
3977
|
-
const createContainerElement = (doc
|
|
4053
|
+
const createContainerElement = (doc) => {
|
|
3978
4054
|
const element = doc.createElement(`div`);
|
|
3979
4055
|
element.style.cssText = `
|
|
3980
4056
|
height: 100%;
|
|
3981
4057
|
position: relative;
|
|
3982
4058
|
`;
|
|
3983
4059
|
element.className = `${HTML_PREFIX$1}-spine`;
|
|
3984
|
-
return
|
|
3985
|
-
if (hook.name === `spine.onBeforeContainerCreated`) {
|
|
3986
|
-
return hook.fn(element2);
|
|
3987
|
-
}
|
|
3988
|
-
return element2;
|
|
3989
|
-
}, element);
|
|
3990
|
-
};
|
|
3991
|
-
const getCoverItem = (manifest) => {
|
|
3992
|
-
var _a;
|
|
3993
|
-
const coverItem = (_a = manifest.guide) == null ? void 0 : _a.find((item) => item.type === `cover`);
|
|
3994
|
-
return manifest.spineItems.findIndex((item) => {
|
|
3995
|
-
if (!(coverItem == null ? void 0 : coverItem.href))
|
|
3996
|
-
return false;
|
|
3997
|
-
return item.href.endsWith(coverItem.href);
|
|
3998
|
-
});
|
|
4060
|
+
return element;
|
|
3999
4061
|
};
|
|
4000
4062
|
const NAMESPACE$4 = `spineItemManager`;
|
|
4001
|
-
const createSpineItemManager = ({ context }) => {
|
|
4063
|
+
const createSpineItemManager = ({ context, settings }) => {
|
|
4002
4064
|
const focus$ = new Subject();
|
|
4003
4065
|
const layout$ = new Subject();
|
|
4004
4066
|
let itemLayoutInformation = [];
|
|
@@ -4008,14 +4070,13 @@ const createSpineItemManager = ({ context }) => {
|
|
|
4008
4070
|
const manifest = context.getManifest();
|
|
4009
4071
|
const newItemLayoutInformation = [];
|
|
4010
4072
|
const isGloballyPrePaginated = (manifest == null ? void 0 : manifest.renditionLayout) === `pre-paginated`;
|
|
4011
|
-
manifest ? getCoverItem(manifest) : void 0;
|
|
4012
4073
|
orderedSpineItemsSubject$.value.reduce(
|
|
4013
4074
|
({ horizontalOffset, verticalOffset }, item, index) => {
|
|
4014
4075
|
let minimumWidth = context.getPageSize().width;
|
|
4015
4076
|
let blankPagePosition = `none`;
|
|
4016
4077
|
const itemStartOnNewScreen = horizontalOffset % context.getVisibleAreaRect().width === 0;
|
|
4017
4078
|
const isLastItem = index === orderedSpineItemsSubject$.value.length - 1;
|
|
4018
|
-
if (context.
|
|
4079
|
+
if (context.isUsingSpreadMode()) {
|
|
4019
4080
|
if (!isGloballyPrePaginated && item.item.renditionLayout === `reflowable` && !isLastItem) {
|
|
4020
4081
|
minimumWidth = context.getPageSize().width * 2;
|
|
4021
4082
|
}
|
|
@@ -4041,9 +4102,9 @@ const createSpineItemManager = ({ context }) => {
|
|
|
4041
4102
|
const { width, height } = item.layout({
|
|
4042
4103
|
minimumWidth,
|
|
4043
4104
|
blankPagePosition,
|
|
4044
|
-
spreadPosition: context.
|
|
4105
|
+
spreadPosition: context.isUsingSpreadMode() ? itemStartOnNewScreen ? context.isRTL() ? `right` : `left` : context.isRTL() ? `left` : `right` : `none`
|
|
4045
4106
|
});
|
|
4046
|
-
if (
|
|
4107
|
+
if (settings.getSettings().computedPageTurnDirection === `vertical`) {
|
|
4047
4108
|
const currentValidEdgeYForVerticalPositioning = itemStartOnNewScreen ? verticalOffset : verticalOffset - context.getVisibleAreaRect().height;
|
|
4048
4109
|
const currentValidEdgeXForVerticalPositioning = itemStartOnNewScreen ? 0 : horizontalOffset;
|
|
4049
4110
|
if (context.isRTL()) {
|
|
@@ -4111,9 +4172,9 @@ const createSpineItemManager = ({ context }) => {
|
|
|
4111
4172
|
const loadContents = Report.measurePerformance(`loadContents`, 10, (rangeOfIndex) => {
|
|
4112
4173
|
var _a;
|
|
4113
4174
|
const [leftIndex, rightIndex] = rangeOfIndex;
|
|
4114
|
-
const numberOfAdjacentSpineItemToPreLoad =
|
|
4175
|
+
const numberOfAdjacentSpineItemToPreLoad = settings.getSettings().numberOfAdjacentSpineItemToPreLoad;
|
|
4115
4176
|
const isPrePaginated = ((_a = context.getManifest()) == null ? void 0 : _a.renditionLayout) === `pre-paginated`;
|
|
4116
|
-
const isUsingFreeScroll =
|
|
4177
|
+
const isUsingFreeScroll = settings.getSettings().computedPageTurnMode === `scrollable`;
|
|
4117
4178
|
orderedSpineItemsSubject$.value.forEach((orderedSpineItem, index) => {
|
|
4118
4179
|
const isBeforeFocusedWithPreload = (
|
|
4119
4180
|
// we never want to preload anything before on free scroll on flow because it could offset the cursor
|
|
@@ -4167,7 +4228,9 @@ const createSpineItemManager = ({ context }) => {
|
|
|
4167
4228
|
spineItem.$.loaded$.pipe(
|
|
4168
4229
|
tap(() => {
|
|
4169
4230
|
if (spineItem.isUsingVerticalWriting()) {
|
|
4170
|
-
context.setHasVerticalWriting();
|
|
4231
|
+
context.setHasVerticalWriting(true);
|
|
4232
|
+
} else {
|
|
4233
|
+
context.setHasVerticalWriting(false);
|
|
4171
4234
|
}
|
|
4172
4235
|
}),
|
|
4173
4236
|
takeUntil$1(context.$.destroy$)
|
|
@@ -4408,9 +4471,10 @@ const createNavigationResolver = ({
|
|
|
4408
4471
|
context,
|
|
4409
4472
|
spineItemManager,
|
|
4410
4473
|
cfiLocator,
|
|
4411
|
-
locator
|
|
4474
|
+
locator,
|
|
4475
|
+
settings
|
|
4412
4476
|
}) => {
|
|
4413
|
-
const spineItemNavigator = createNavigationResolver$1({ context });
|
|
4477
|
+
const spineItemNavigator = createNavigationResolver$1({ context, settings });
|
|
4414
4478
|
const arePositionsDifferent = (a, b) => a.x !== b.x || a.y !== b.y;
|
|
4415
4479
|
const areNavigationDifferent = (a, b) => arePositionsDifferent(a, b) || !!a.spineItem && !!b.spineItem && a.spineItem !== b.spineItem;
|
|
4416
4480
|
const wrapPositionWithSafeEdge = Report.measurePerformance(
|
|
@@ -4475,7 +4539,7 @@ const createNavigationResolver = ({
|
|
|
4475
4539
|
return { x: 0, y: 0 };
|
|
4476
4540
|
};
|
|
4477
4541
|
const getNavigationForRightSinglePage = (position) => {
|
|
4478
|
-
const pageTurnDirection =
|
|
4542
|
+
const pageTurnDirection = settings.getSettings().computedPageTurnDirection;
|
|
4479
4543
|
const spineItem = locator.getSpineItemFromPosition(position) || spineItemManager.getFocusedSpineItem();
|
|
4480
4544
|
const defaultNavigation = position;
|
|
4481
4545
|
if (!spineItem) {
|
|
@@ -4494,7 +4558,7 @@ const createNavigationResolver = ({
|
|
|
4494
4558
|
}
|
|
4495
4559
|
};
|
|
4496
4560
|
const getNavigationForLeftSinglePage = (position) => {
|
|
4497
|
-
const pageTurnDirection =
|
|
4561
|
+
const pageTurnDirection = settings.getSettings().computedPageTurnDirection;
|
|
4498
4562
|
const spineItem = locator.getSpineItemFromPosition(position) || spineItemManager.getFocusedSpineItem();
|
|
4499
4563
|
const defaultNavigation = { ...position, spineItem };
|
|
4500
4564
|
if (!spineItem) {
|
|
@@ -4518,7 +4582,7 @@ const createNavigationResolver = ({
|
|
|
4518
4582
|
if ((spineItemOnPosition == null ? void 0 : spineItemOnPosition.isUsingVerticalWriting()) && position.x === navigation.x) {
|
|
4519
4583
|
return getAdjustedPositionForSpread(navigation);
|
|
4520
4584
|
}
|
|
4521
|
-
if (context.
|
|
4585
|
+
if (context.isUsingSpreadMode()) {
|
|
4522
4586
|
if ((spineItemOnPosition == null ? void 0 : spineItemOnPosition.isUsingVerticalWriting()) && position.x !== navigation.x) {
|
|
4523
4587
|
return getAdjustedPositionForSpread(
|
|
4524
4588
|
wrapPositionWithSafeEdge(
|
|
@@ -4532,7 +4596,7 @@ const createNavigationResolver = ({
|
|
|
4532
4596
|
)
|
|
4533
4597
|
);
|
|
4534
4598
|
}
|
|
4535
|
-
if (
|
|
4599
|
+
if (settings.getSettings().computedPageTurnDirection === `vertical` && position.y !== navigation.y) {
|
|
4536
4600
|
return getAdjustedPositionForSpread(navigation);
|
|
4537
4601
|
}
|
|
4538
4602
|
const doubleNavigation = getNavigationForRightSinglePage(navigation);
|
|
@@ -4546,7 +4610,7 @@ const createNavigationResolver = ({
|
|
|
4546
4610
|
if ((spineItemOnPosition == null ? void 0 : spineItemOnPosition.isUsingVerticalWriting()) && position.x === navigation.x) {
|
|
4547
4611
|
return getAdjustedPositionForSpread(navigation);
|
|
4548
4612
|
}
|
|
4549
|
-
if (context.
|
|
4613
|
+
if (context.isUsingSpreadMode()) {
|
|
4550
4614
|
if ((spineItemOnPosition == null ? void 0 : spineItemOnPosition.isUsingVerticalWriting()) && position.x !== navigation.x) {
|
|
4551
4615
|
return getAdjustedPositionForSpread(
|
|
4552
4616
|
wrapPositionWithSafeEdge(
|
|
@@ -4554,7 +4618,7 @@ const createNavigationResolver = ({
|
|
|
4554
4618
|
)
|
|
4555
4619
|
);
|
|
4556
4620
|
}
|
|
4557
|
-
if (
|
|
4621
|
+
if (settings.getSettings().computedPageTurnDirection === `vertical` && position.y !== navigation.y) {
|
|
4558
4622
|
return getAdjustedPositionForSpread(navigation);
|
|
4559
4623
|
}
|
|
4560
4624
|
const doubleNavigation = getNavigationForLeftSinglePage(navigation);
|
|
@@ -4596,7 +4660,7 @@ const createNavigationResolver = ({
|
|
|
4596
4660
|
return { x: 0, y: 0 };
|
|
4597
4661
|
};
|
|
4598
4662
|
const getMostPredominantNavigationForPosition = (viewportPosition) => {
|
|
4599
|
-
const pageTurnDirection =
|
|
4663
|
+
const pageTurnDirection = settings.getSettings().computedPageTurnDirection;
|
|
4600
4664
|
const triggerPercentage = 0.5;
|
|
4601
4665
|
const triggerXPosition = pageTurnDirection === `horizontal` ? viewportPosition.x + context.getVisibleAreaRect().width * triggerPercentage : 0;
|
|
4602
4666
|
const triggerYPosition = pageTurnDirection === `horizontal` ? 0 : viewportPosition.y + context.getVisibleAreaRect().height * triggerPercentage;
|
|
@@ -4604,7 +4668,7 @@ const createNavigationResolver = ({
|
|
|
4604
4668
|
return getNavigationForPosition(midScreenPositionSafePosition);
|
|
4605
4669
|
};
|
|
4606
4670
|
const isNavigationGoingForwardFrom = (to, from2) => {
|
|
4607
|
-
const pageTurnDirection =
|
|
4671
|
+
const pageTurnDirection = settings.getSettings().computedPageTurnDirection;
|
|
4608
4672
|
if (pageTurnDirection === `vertical`) {
|
|
4609
4673
|
return to.y > from2.y;
|
|
4610
4674
|
}
|
|
@@ -4630,9 +4694,10 @@ const createNavigationResolver = ({
|
|
|
4630
4694
|
const SCROLL_FINISHED_DEBOUNCE_TIMEOUT = 200;
|
|
4631
4695
|
const createScrollViewportNavigator = ({
|
|
4632
4696
|
context,
|
|
4633
|
-
element
|
|
4697
|
+
element$,
|
|
4634
4698
|
navigator: navigator2,
|
|
4635
4699
|
currentNavigationSubject$,
|
|
4700
|
+
settings,
|
|
4636
4701
|
spine
|
|
4637
4702
|
}) => {
|
|
4638
4703
|
let lastScrollWasProgrammaticallyTriggered = false;
|
|
@@ -4646,38 +4711,44 @@ const createScrollViewportNavigator = ({
|
|
|
4646
4711
|
})
|
|
4647
4712
|
);
|
|
4648
4713
|
const adjustReadingOffset = ({ x, y }) => {
|
|
4649
|
-
|
|
4714
|
+
var _a;
|
|
4715
|
+
if (settings.getSettings().computedPageTurnMode === `scrollable`) {
|
|
4650
4716
|
lastScrollWasProgrammaticallyTriggered = true;
|
|
4651
|
-
element.scrollTo({ left: x, top: y });
|
|
4717
|
+
(_a = element$.getValue()) == null ? void 0 : _a.scrollTo({ left: x, top: y });
|
|
4652
4718
|
return true;
|
|
4653
4719
|
}
|
|
4654
4720
|
return false;
|
|
4655
4721
|
};
|
|
4656
|
-
const runOnFreePageTurnModeOnly$ = (source) =>
|
|
4657
|
-
map$1(() =>
|
|
4722
|
+
const runOnFreePageTurnModeOnly$ = (source) => settings.$.settings$.pipe(
|
|
4723
|
+
map$1(({ computedPageTurnMode }) => computedPageTurnMode),
|
|
4658
4724
|
distinctUntilChanged(),
|
|
4659
4725
|
switchMap$1((mode) => iif(() => mode === `controlled`, EMPTY, source))
|
|
4660
4726
|
);
|
|
4661
|
-
const userScroll$ = runOnFreePageTurnModeOnly$(
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4727
|
+
const userScroll$ = runOnFreePageTurnModeOnly$(
|
|
4728
|
+
element$.pipe(
|
|
4729
|
+
filter(isDefined),
|
|
4730
|
+
switchMap$1((element) => fromEvent(element, `scroll`))
|
|
4731
|
+
)
|
|
4732
|
+
).pipe(onlyUserScrollFilter, share(), takeUntil$1(context.$.destroy$));
|
|
4666
4733
|
const getScaledDownPosition = ({ x, y }) => {
|
|
4667
|
-
|
|
4734
|
+
var _a, _b;
|
|
4735
|
+
const spineElement = spine.getElement();
|
|
4736
|
+
if (!spineElement)
|
|
4737
|
+
throw new Error("Invalid spine element");
|
|
4738
|
+
const spineScaleX = spineElement.getBoundingClientRect().width / spineElement.offsetWidth;
|
|
4668
4739
|
const scaledDownPosition = {
|
|
4669
4740
|
x: getNewScaledOffset({
|
|
4670
4741
|
newScale: 1,
|
|
4671
4742
|
oldScale: spineScaleX,
|
|
4672
|
-
screenSize: element.clientWidth,
|
|
4673
|
-
pageSize:
|
|
4743
|
+
screenSize: ((_a = element$.getValue()) == null ? void 0 : _a.clientWidth) ?? 0,
|
|
4744
|
+
pageSize: spineElement.scrollWidth,
|
|
4674
4745
|
scrollOffset: x
|
|
4675
4746
|
}),
|
|
4676
4747
|
y: getNewScaledOffset({
|
|
4677
4748
|
newScale: 1,
|
|
4678
4749
|
oldScale: spineScaleX,
|
|
4679
|
-
screenSize: element.clientHeight,
|
|
4680
|
-
pageSize:
|
|
4750
|
+
screenSize: ((_b = element$.getValue()) == null ? void 0 : _b.clientHeight) ?? 0,
|
|
4751
|
+
pageSize: spineElement.scrollHeight,
|
|
4681
4752
|
scrollOffset: y
|
|
4682
4753
|
})
|
|
4683
4754
|
};
|
|
@@ -4688,13 +4759,17 @@ const createScrollViewportNavigator = ({
|
|
|
4688
4759
|
return navigation;
|
|
4689
4760
|
};
|
|
4690
4761
|
const getCurrentViewportPosition = () => {
|
|
4691
|
-
|
|
4762
|
+
var _a, _b;
|
|
4763
|
+
return getScaledDownPosition({ x: ((_a = element$.getValue()) == null ? void 0 : _a.scrollLeft) ?? 0, y: ((_b = element$.getValue()) == null ? void 0 : _b.scrollTop) ?? 0 });
|
|
4692
4764
|
};
|
|
4693
4765
|
const navigationOnScroll$ = userScroll$.pipe(
|
|
4694
4766
|
debounceTime(SCROLL_FINISHED_DEBOUNCE_TIMEOUT, animationFrameScheduler),
|
|
4695
4767
|
withLatestFrom(currentNavigationSubject$),
|
|
4696
4768
|
switchMap$1(() => {
|
|
4697
|
-
|
|
4769
|
+
var _a, _b;
|
|
4770
|
+
const navigation = getNavigationForPosition(
|
|
4771
|
+
getScaledDownPosition({ x: ((_a = element$.getValue()) == null ? void 0 : _a.scrollLeft) ?? 0, y: ((_b = element$.getValue()) == null ? void 0 : _b.scrollTop) ?? 0 })
|
|
4772
|
+
);
|
|
4698
4773
|
return of({ position: navigation, animate: false, lastUserExpectedNavigation: void 0 });
|
|
4699
4774
|
}),
|
|
4700
4775
|
share()
|
|
@@ -4917,7 +4992,8 @@ const createPanViewportNavigator = ({
|
|
|
4917
4992
|
spineItemManager,
|
|
4918
4993
|
locator,
|
|
4919
4994
|
context,
|
|
4920
|
-
currentNavigationSubject
|
|
4995
|
+
currentNavigationSubject$,
|
|
4996
|
+
settings
|
|
4921
4997
|
}) => {
|
|
4922
4998
|
const navigationTriggerSubject$ = new Subject();
|
|
4923
4999
|
const stateSubject$ = new BehaviorSubject(`end`);
|
|
@@ -4928,11 +5004,11 @@ const createPanViewportNavigator = ({
|
|
|
4928
5004
|
`${NAMESPACE$1} moveTo`,
|
|
4929
5005
|
5,
|
|
4930
5006
|
(delta, { final, start } = {}) => {
|
|
4931
|
-
if (
|
|
5007
|
+
if (settings.getSettings().computedPageTurnMode === `scrollable`) {
|
|
4932
5008
|
Report.warn(`pan control is not available on free page turn mode`);
|
|
4933
5009
|
return;
|
|
4934
5010
|
}
|
|
4935
|
-
const pageTurnDirection =
|
|
5011
|
+
const pageTurnDirection = settings.getSettings().computedPageTurnDirection;
|
|
4936
5012
|
if (start) {
|
|
4937
5013
|
stateSubject$.next(`start`);
|
|
4938
5014
|
movingLastDelta = { x: 0, y: 0 };
|
|
@@ -4992,7 +5068,7 @@ const createPanViewportNavigator = ({
|
|
|
4992
5068
|
);
|
|
4993
5069
|
const snapNavigation$ = navigationTriggerSubject$.pipe(
|
|
4994
5070
|
filter((e) => e.type === `snap`),
|
|
4995
|
-
withLatestFrom$1(
|
|
5071
|
+
withLatestFrom$1(settings.$.settings$),
|
|
4996
5072
|
switchMap$1(
|
|
4997
5073
|
([
|
|
4998
5074
|
{
|
|
@@ -5000,7 +5076,7 @@ const createPanViewportNavigator = ({
|
|
|
5000
5076
|
},
|
|
5001
5077
|
{ navigationSnapThreshold }
|
|
5002
5078
|
]) => {
|
|
5003
|
-
const pageTurnDirection =
|
|
5079
|
+
const pageTurnDirection = settings.getSettings().computedPageTurnDirection;
|
|
5004
5080
|
const movingForward = navigator2.isNavigationGoingForwardFrom(to, from2);
|
|
5005
5081
|
const triggerPercentage = movingForward ? 1 - navigationSnapThreshold : navigationSnapThreshold;
|
|
5006
5082
|
const triggerXPosition = pageTurnDirection === `horizontal` ? to.x + context.getVisibleAreaRect().width * triggerPercentage : 0;
|
|
@@ -5033,18 +5109,19 @@ const createPanViewportNavigator = ({
|
|
|
5033
5109
|
};
|
|
5034
5110
|
};
|
|
5035
5111
|
const NAMESPACE = `viewportNavigator`;
|
|
5112
|
+
const noopElement = document.createElement("div");
|
|
5036
5113
|
const createViewportNavigator = ({
|
|
5037
5114
|
spineItemManager,
|
|
5038
5115
|
context,
|
|
5039
5116
|
pagination,
|
|
5040
|
-
parentElement
|
|
5117
|
+
parentElement$,
|
|
5041
5118
|
cfiLocator,
|
|
5042
5119
|
spineLocator,
|
|
5043
5120
|
hooks$,
|
|
5044
|
-
spine
|
|
5121
|
+
spine,
|
|
5122
|
+
settings
|
|
5045
5123
|
}) => {
|
|
5046
|
-
const element =
|
|
5047
|
-
element.appendChild(spine.element);
|
|
5124
|
+
const element$ = new BehaviorSubject(noopElement);
|
|
5048
5125
|
const layoutSubject$ = new Subject();
|
|
5049
5126
|
let currentViewportPositionMemoUnused;
|
|
5050
5127
|
const currentNavigationPositionSubject$ = new BehaviorSubject({
|
|
@@ -5054,17 +5131,18 @@ const createViewportNavigator = ({
|
|
|
5054
5131
|
});
|
|
5055
5132
|
const navigator2 = createNavigationResolver({
|
|
5056
5133
|
context,
|
|
5134
|
+
settings,
|
|
5057
5135
|
spineItemManager,
|
|
5058
5136
|
cfiLocator,
|
|
5059
5137
|
locator: spineLocator
|
|
5060
5138
|
});
|
|
5061
5139
|
const adjustNavigationSubject$ = new Subject();
|
|
5062
|
-
parentElement.appendChild(element);
|
|
5063
5140
|
const getCurrentViewportPosition = Report.measurePerformance(`${NAMESPACE} getCurrentViewportPosition`, 1, () => {
|
|
5064
|
-
|
|
5141
|
+
var _a;
|
|
5142
|
+
if (settings.getSettings().computedPageTurnMode === `scrollable`) {
|
|
5065
5143
|
return scrollViewportNavigator.getCurrentViewportPosition();
|
|
5066
5144
|
}
|
|
5067
|
-
const { x, y } = element.getBoundingClientRect();
|
|
5145
|
+
const { x, y } = ((_a = element$.getValue()) == null ? void 0 : _a.getBoundingClientRect()) ?? { x: 0, y: 0 };
|
|
5068
5146
|
const newValue = {
|
|
5069
5147
|
// we want to round to first decimal because it's possible to have half pixel
|
|
5070
5148
|
// however browser engine can also gives back x.yyyy based on their precision
|
|
@@ -5078,7 +5156,7 @@ const createViewportNavigator = ({
|
|
|
5078
5156
|
});
|
|
5079
5157
|
const panViewportNavigator = createPanViewportNavigator({
|
|
5080
5158
|
context,
|
|
5081
|
-
|
|
5159
|
+
settings,
|
|
5082
5160
|
navigator: navigator2,
|
|
5083
5161
|
spineItemManager,
|
|
5084
5162
|
locator: spineLocator,
|
|
@@ -5087,15 +5165,15 @@ const createViewportNavigator = ({
|
|
|
5087
5165
|
});
|
|
5088
5166
|
const scrollViewportNavigator = createScrollViewportNavigator({
|
|
5089
5167
|
context,
|
|
5090
|
-
element
|
|
5168
|
+
element$,
|
|
5091
5169
|
navigator: navigator2,
|
|
5092
5170
|
currentNavigationSubject$: currentNavigationPositionSubject$,
|
|
5093
5171
|
spine,
|
|
5094
|
-
spineItemManager
|
|
5172
|
+
spineItemManager,
|
|
5173
|
+
settings
|
|
5095
5174
|
});
|
|
5096
5175
|
const manualViewportNavigator = createManualViewportNavigator({
|
|
5097
5176
|
context,
|
|
5098
|
-
element,
|
|
5099
5177
|
navigator: navigator2,
|
|
5100
5178
|
currentNavigationSubject$: currentNavigationPositionSubject$,
|
|
5101
5179
|
spineItemManager,
|
|
@@ -5112,6 +5190,9 @@ const createViewportNavigator = ({
|
|
|
5112
5190
|
`adjustReadingOffset`,
|
|
5113
5191
|
2,
|
|
5114
5192
|
({ x, y }, hooks) => {
|
|
5193
|
+
const element = element$.getValue();
|
|
5194
|
+
if (!element)
|
|
5195
|
+
throw new Error("Invalid element");
|
|
5115
5196
|
currentViewportPositionMemoUnused = void 0;
|
|
5116
5197
|
const isAdjusted = viewportNavigators.reduce((isAdjusted2, navigator22) => {
|
|
5117
5198
|
return navigator22.adjustReadingOffset({ x, y }) || isAdjusted2;
|
|
@@ -5128,10 +5209,10 @@ const createViewportNavigator = ({
|
|
|
5128
5209
|
{ disable: true }
|
|
5129
5210
|
);
|
|
5130
5211
|
const adjustNavigation = (spineItem) => {
|
|
5131
|
-
const lastCfi = pagination.
|
|
5212
|
+
const lastCfi = pagination.getPaginationInfo().beginCfi;
|
|
5132
5213
|
let adjustedSpinePosition = currentNavigationPositionSubject$.value;
|
|
5133
5214
|
const offsetInSpineItem = 0;
|
|
5134
|
-
if (
|
|
5215
|
+
if (settings.getSettings().computedPageTurnMode === `scrollable`) {
|
|
5135
5216
|
adjustedSpinePosition = scrollViewportNavigator.getNavigationForPosition(getCurrentViewportPosition());
|
|
5136
5217
|
} else if ((lastUserExpectedNavigation == null ? void 0 : lastUserExpectedNavigation.type) === `navigate-from-cfi`) {
|
|
5137
5218
|
adjustedSpinePosition = navigator2.getNavigationForCfi(lastUserExpectedNavigation.data);
|
|
@@ -5149,7 +5230,7 @@ const createViewportNavigator = ({
|
|
|
5149
5230
|
adjustedSpinePosition = navigator2.getNavigationForCfi(lastCfi);
|
|
5150
5231
|
Report.log(NAMESPACE, `adjustNavigation`, `use last cfi`);
|
|
5151
5232
|
} else {
|
|
5152
|
-
const currentPageIndex = pagination.
|
|
5233
|
+
const currentPageIndex = pagination.getPaginationInfo().beginPageIndexInSpineItem || 0;
|
|
5153
5234
|
adjustedSpinePosition = navigator2.getNavigationForPage(currentPageIndex, spineItem);
|
|
5154
5235
|
Report.log(NAMESPACE, `adjustNavigation`, `use guess strategy`, {});
|
|
5155
5236
|
}
|
|
@@ -5176,14 +5257,15 @@ const createViewportNavigator = ({
|
|
|
5176
5257
|
layoutSubject$.subscribe(() => {
|
|
5177
5258
|
currentViewportPositionMemoUnused = void 0;
|
|
5178
5259
|
});
|
|
5179
|
-
const layoutChangeSettings$ =
|
|
5260
|
+
const layoutChangeSettings$ = settings.$.settings$.pipe(
|
|
5180
5261
|
mapKeysTo([`computedPageTurnDirection`, `computedPageTurnMode`, `numberOfAdjacentSpineItemToPreLoad`]),
|
|
5181
5262
|
distinctUntilChanged(isShallowEqual),
|
|
5182
5263
|
skip(1)
|
|
5183
5264
|
);
|
|
5184
5265
|
const layout$ = merge(layoutSubject$, layoutChangeSettings$).pipe(
|
|
5185
|
-
|
|
5186
|
-
|
|
5266
|
+
withLatestFrom(element$),
|
|
5267
|
+
tap(([, element]) => {
|
|
5268
|
+
if (settings.getSettings().computedPageTurnMode === `scrollable`) {
|
|
5187
5269
|
element.style.removeProperty(`transform`);
|
|
5188
5270
|
element.style.removeProperty(`transition`);
|
|
5189
5271
|
element.style.overflow = `scroll`;
|
|
@@ -5239,7 +5321,7 @@ const createViewportNavigator = ({
|
|
|
5239
5321
|
);
|
|
5240
5322
|
const navigationWhichRequireManualAdjust$ = navigation$.pipe(
|
|
5241
5323
|
filter(({ triggeredBy }) => {
|
|
5242
|
-
if (triggeredBy === `scroll` ||
|
|
5324
|
+
if (triggeredBy === `scroll` || settings.getSettings().computedPageTurnMode === `scrollable` && triggeredBy === `adjust`) {
|
|
5243
5325
|
return false;
|
|
5244
5326
|
} else {
|
|
5245
5327
|
return true;
|
|
@@ -5251,7 +5333,7 @@ const createViewportNavigator = ({
|
|
|
5251
5333
|
navigationWhichRequireManualAdjust$
|
|
5252
5334
|
).pipe(
|
|
5253
5335
|
map$1(({ animation, position }) => {
|
|
5254
|
-
const shouldAnimate = !(!animation || animation === `turn` &&
|
|
5336
|
+
const shouldAnimate = !(!animation || animation === `turn` && settings.getSettings().computedPageTurnAnimation === `none`);
|
|
5255
5337
|
return {
|
|
5256
5338
|
type: `manualAdjust`,
|
|
5257
5339
|
shouldAnimate,
|
|
@@ -5266,15 +5348,15 @@ const createViewportNavigator = ({
|
|
|
5266
5348
|
pairwise(),
|
|
5267
5349
|
tap(([prevEvent, currentEvent]) => {
|
|
5268
5350
|
if ((prevEvent == null ? void 0 : prevEvent.type) === `manualAdjust` && (currentEvent == null ? void 0 : currentEvent.type) !== `manualAdjust`) {
|
|
5269
|
-
element.style.setProperty(`transition`, `none`);
|
|
5270
|
-
element.style.setProperty(`opacity`, `1`);
|
|
5351
|
+
element$.getValue().style.setProperty(`transition`, `none`);
|
|
5352
|
+
element$.getValue().style.setProperty(`opacity`, `1`);
|
|
5271
5353
|
}
|
|
5272
5354
|
}),
|
|
5273
5355
|
switchMap$1(([, currentEvent]) => {
|
|
5274
5356
|
if ((currentEvent == null ? void 0 : currentEvent.type) !== `manualAdjust`)
|
|
5275
5357
|
return EMPTY;
|
|
5276
|
-
const animationDuration = currentEvent.animation === `snap` ?
|
|
5277
|
-
const pageTurnAnimation = currentEvent.animation === `snap` ? `slide` :
|
|
5358
|
+
const animationDuration = currentEvent.animation === `snap` ? settings.getSettings().computedSnapAnimationDuration : settings.getSettings().computedPageTurnAnimationDuration;
|
|
5359
|
+
const pageTurnAnimation = currentEvent.animation === `snap` ? `slide` : settings.getSettings().computedPageTurnAnimation;
|
|
5278
5360
|
return of(currentEvent).pipe(
|
|
5279
5361
|
/**
|
|
5280
5362
|
* @important
|
|
@@ -5289,15 +5371,15 @@ const createViewportNavigator = ({
|
|
|
5289
5371
|
const noAdjustmentNeeded = false;
|
|
5290
5372
|
if (data.shouldAnimate && !noAdjustmentNeeded) {
|
|
5291
5373
|
if (pageTurnAnimation === `fade`) {
|
|
5292
|
-
element.style.setProperty(`transition`, `opacity ${animationDuration / 2}ms`);
|
|
5293
|
-
element.style.setProperty(`opacity`, `0`);
|
|
5374
|
+
element$.getValue().style.setProperty(`transition`, `opacity ${animationDuration / 2}ms`);
|
|
5375
|
+
element$.getValue().style.setProperty(`opacity`, `0`);
|
|
5294
5376
|
} else if (currentEvent.animation === `snap` || pageTurnAnimation === `slide`) {
|
|
5295
|
-
element.style.setProperty(`transition`, `transform ${animationDuration}ms`);
|
|
5296
|
-
element.style.setProperty(`opacity`, `1`);
|
|
5377
|
+
element$.getValue().style.setProperty(`transition`, `transform ${animationDuration}ms`);
|
|
5378
|
+
element$.getValue().style.setProperty(`opacity`, `1`);
|
|
5297
5379
|
}
|
|
5298
5380
|
} else {
|
|
5299
|
-
element.style.setProperty(`transition`, `none`);
|
|
5300
|
-
element.style.setProperty(`opacity`, `1`);
|
|
5381
|
+
element$.getValue().style.setProperty(`transition`, `none`);
|
|
5382
|
+
element$.getValue().style.setProperty(`opacity`, `1`);
|
|
5301
5383
|
}
|
|
5302
5384
|
}),
|
|
5303
5385
|
/**
|
|
@@ -5318,7 +5400,7 @@ const createViewportNavigator = ({
|
|
|
5318
5400
|
tap(([data, hooks]) => {
|
|
5319
5401
|
if (pageTurnAnimation === `fade`) {
|
|
5320
5402
|
adjustReadingOffset(data.position, hooks);
|
|
5321
|
-
element.style.setProperty(`opacity`, `1`);
|
|
5403
|
+
element$.getValue().style.setProperty(`opacity`, `1`);
|
|
5322
5404
|
}
|
|
5323
5405
|
}),
|
|
5324
5406
|
currentEvent.shouldAnimate ? delay(animationDuration / 2, animationFrameScheduler) : identity,
|
|
@@ -5390,10 +5472,17 @@ const createViewportNavigator = ({
|
|
|
5390
5472
|
),
|
|
5391
5473
|
share()
|
|
5392
5474
|
);
|
|
5475
|
+
const parentElementSub = parentElement$.pipe(filter(isDefined), withLatestFrom(spine.element$)).subscribe(([parentElement, spineElement]) => {
|
|
5476
|
+
const element = createElement(parentElement.ownerDocument, hooks$);
|
|
5477
|
+
element.appendChild(spineElement);
|
|
5478
|
+
parentElement.appendChild(element);
|
|
5479
|
+
element$.next(element);
|
|
5480
|
+
});
|
|
5393
5481
|
const destroy = () => {
|
|
5394
5482
|
layoutSubject$.complete();
|
|
5395
5483
|
adjustNavigationSubject$.complete();
|
|
5396
5484
|
currentNavigationPositionSubject$.complete();
|
|
5485
|
+
parentElementSub.unsubscribe();
|
|
5397
5486
|
viewportNavigators.forEach((navigator22) => navigator22.destroy());
|
|
5398
5487
|
};
|
|
5399
5488
|
return {
|
|
@@ -5410,7 +5499,8 @@ const createViewportNavigator = ({
|
|
|
5410
5499
|
goToPageOfCurrentChapter: manualViewportNavigator.goToPageOfCurrentChapter,
|
|
5411
5500
|
moveTo: panViewportNavigator.moveTo,
|
|
5412
5501
|
getLastUserExpectedNavigation: () => lastUserExpectedNavigation,
|
|
5413
|
-
element
|
|
5502
|
+
element$,
|
|
5503
|
+
getElement: () => element$.getValue(),
|
|
5414
5504
|
$: {
|
|
5415
5505
|
state$,
|
|
5416
5506
|
navigation$,
|
|
@@ -5436,7 +5526,8 @@ const createElement = (doc, hooks$) => {
|
|
|
5436
5526
|
const createLocationResolver = ({
|
|
5437
5527
|
spineItemManager,
|
|
5438
5528
|
context,
|
|
5439
|
-
spineItemLocator
|
|
5529
|
+
spineItemLocator,
|
|
5530
|
+
settings
|
|
5440
5531
|
}) => {
|
|
5441
5532
|
const getSpineItemPositionFromSpinePosition = Report.measurePerformance(
|
|
5442
5533
|
`getSpineItemPositionFromSpinePosition`,
|
|
@@ -5471,7 +5562,7 @@ const createLocationResolver = ({
|
|
|
5471
5562
|
const spineItem = spineItemManager.getAll().find((item) => {
|
|
5472
5563
|
const { left, right, bottom, top } = spineItemManager.getAbsolutePositionOf(item);
|
|
5473
5564
|
const isWithinXAxis = position.x >= left && position.x < right;
|
|
5474
|
-
if (
|
|
5565
|
+
if (settings.getSettings().computedPageTurnDirection === `horizontal`) {
|
|
5475
5566
|
return isWithinXAxis;
|
|
5476
5567
|
} else {
|
|
5477
5568
|
return isWithinXAxis && position.y >= top && position.y < bottom;
|
|
@@ -5498,7 +5589,7 @@ const createLocationResolver = ({
|
|
|
5498
5589
|
if (itemAtPositionIndex === void 0)
|
|
5499
5590
|
return void 0;
|
|
5500
5591
|
let endPosition = position;
|
|
5501
|
-
if (context.
|
|
5592
|
+
if (context.isUsingSpreadMode()) {
|
|
5502
5593
|
endPosition = { x: position.x + context.getPageSize().width, y: position.y };
|
|
5503
5594
|
}
|
|
5504
5595
|
const endItemIndex = spineItemManager.getSpineItemIndex(getSpineItemFromPosition(endPosition) || spineItemManager.getFocusedSpineItem()) ?? itemAtPositionIndex;
|
|
@@ -5619,15 +5710,86 @@ const createCfiLocator = ({
|
|
|
5619
5710
|
generateFromRange
|
|
5620
5711
|
};
|
|
5621
5712
|
};
|
|
5713
|
+
const areAllItemsPrePaginated = (manifest) => !(manifest == null ? void 0 : manifest.spineItems.some((item) => item.renditionLayout === `reflowable`));
|
|
5714
|
+
const createSettings = (initialSettings) => {
|
|
5715
|
+
const mergedSettings = {
|
|
5716
|
+
forceSinglePageMode: false,
|
|
5717
|
+
pageTurnAnimation: `none`,
|
|
5718
|
+
computedPageTurnAnimation: `none`,
|
|
5719
|
+
pageTurnDirection: `horizontal`,
|
|
5720
|
+
computedPageTurnDirection: `horizontal`,
|
|
5721
|
+
pageTurnAnimationDuration: void 0,
|
|
5722
|
+
computedPageTurnAnimationDuration: 0,
|
|
5723
|
+
pageTurnMode: `controlled`,
|
|
5724
|
+
computedPageTurnMode: `controlled`,
|
|
5725
|
+
computedSnapAnimationDuration: 300,
|
|
5726
|
+
navigationSnapThreshold: 0.3,
|
|
5727
|
+
numberOfAdjacentSpineItemToPreLoad: 0,
|
|
5728
|
+
...initialSettings
|
|
5729
|
+
};
|
|
5730
|
+
updateComputedSettings(void 0, mergedSettings, false);
|
|
5731
|
+
const settingsSubject$ = new BehaviorSubject(mergedSettings);
|
|
5732
|
+
const setSettings = (newSettings, options) => {
|
|
5733
|
+
if (Object.keys(newSettings).length === 0)
|
|
5734
|
+
return;
|
|
5735
|
+
const newMergedSettings = { ...settingsSubject$.value, ...newSettings };
|
|
5736
|
+
updateComputedSettings(options.manifest, newMergedSettings, options.hasVerticalWriting ?? false);
|
|
5737
|
+
settingsSubject$.next(newMergedSettings);
|
|
5738
|
+
};
|
|
5739
|
+
const recompute = (options) => {
|
|
5740
|
+
const newMergedSettings = { ...settingsSubject$.value };
|
|
5741
|
+
updateComputedSettings(options.manifest, newMergedSettings, options.hasVerticalWriting ?? false);
|
|
5742
|
+
settingsSubject$.next(newMergedSettings);
|
|
5743
|
+
};
|
|
5744
|
+
const destroy = () => {
|
|
5745
|
+
settingsSubject$.complete();
|
|
5746
|
+
};
|
|
5747
|
+
return {
|
|
5748
|
+
getSettings: () => settingsSubject$.value,
|
|
5749
|
+
setSettings,
|
|
5750
|
+
recompute,
|
|
5751
|
+
destroy,
|
|
5752
|
+
$: {
|
|
5753
|
+
settings$: settingsSubject$.asObservable().pipe(distinctUntilChanged(isShallowEqual))
|
|
5754
|
+
}
|
|
5755
|
+
};
|
|
5756
|
+
};
|
|
5757
|
+
const updateComputedSettings = (newManifest, settings, hasVerticalWriting) => {
|
|
5758
|
+
settings.computedPageTurnDirection = settings.pageTurnDirection;
|
|
5759
|
+
settings.computedPageTurnAnimation = settings.pageTurnAnimation;
|
|
5760
|
+
settings.computedPageTurnMode = `controlled`;
|
|
5761
|
+
if ((newManifest == null ? void 0 : newManifest.renditionFlow) === `scrolled-continuous`) {
|
|
5762
|
+
settings.computedPageTurnMode = `scrollable`;
|
|
5763
|
+
settings.computedPageTurnDirection = `vertical`;
|
|
5764
|
+
} else if (newManifest && settings.pageTurnMode === `scrollable` && (newManifest.renditionLayout !== `pre-paginated` || !areAllItemsPrePaginated(newManifest))) {
|
|
5765
|
+
Report.warn(`pageTurnMode ${settings.pageTurnMode} incompatible with current book, switching back to default`);
|
|
5766
|
+
settings.computedPageTurnAnimation = `none`;
|
|
5767
|
+
settings.computedPageTurnMode = `controlled`;
|
|
5768
|
+
} else if (settings.pageTurnMode === `scrollable`) {
|
|
5769
|
+
settings.computedPageTurnMode = `scrollable`;
|
|
5770
|
+
settings.computedPageTurnDirection = `vertical`;
|
|
5771
|
+
}
|
|
5772
|
+
if (hasVerticalWriting && settings.computedPageTurnAnimation === `slide`) {
|
|
5773
|
+
Report.warn(
|
|
5774
|
+
`pageTurnAnimation ${settings.computedPageTurnAnimation} incompatible with current book, switching back to default`
|
|
5775
|
+
);
|
|
5776
|
+
settings.computedPageTurnAnimation = `none`;
|
|
5777
|
+
}
|
|
5778
|
+
if (settings.computedPageTurnMode === `scrollable`) {
|
|
5779
|
+
settings.computedPageTurnAnimationDuration = 0;
|
|
5780
|
+
settings.computedPageTurnAnimation = `none`;
|
|
5781
|
+
} else {
|
|
5782
|
+
settings.computedPageTurnAnimationDuration = settings.pageTurnAnimationDuration !== void 0 ? settings.pageTurnAnimationDuration : 300;
|
|
5783
|
+
}
|
|
5784
|
+
};
|
|
5622
5785
|
const IFRAME_EVENT_BRIDGE_ELEMENT_ID = `proseReaderIframeEventBridgeElement`;
|
|
5623
|
-
const createReader = ({
|
|
5786
|
+
const createReader = ({ hooks: initialHooks, ...inputSettings }) => {
|
|
5624
5787
|
const stateSubject$ = new BehaviorSubject({
|
|
5625
5788
|
supportedPageTurnAnimation: [`fade`, `none`, `slide`],
|
|
5626
5789
|
supportedPageTurnMode: [`controlled`, `scrollable`],
|
|
5627
5790
|
supportedPageTurnDirection: [`horizontal`, `vertical`],
|
|
5628
5791
|
supportedComputedPageTurnDirection: [`horizontal`, `vertical`]
|
|
5629
5792
|
});
|
|
5630
|
-
const readySubject$ = new Subject();
|
|
5631
5793
|
const destroy$ = new Subject();
|
|
5632
5794
|
const selectionSubject$ = new Subject();
|
|
5633
5795
|
const hooksSubject$ = new BehaviorSubject(initialHooks || []);
|
|
@@ -5635,16 +5797,19 @@ const createReader = ({ containerElement, hooks: initialHooks, ...settings }) =>
|
|
|
5635
5797
|
const navigationAdjustedSubject = new Subject();
|
|
5636
5798
|
const currentNavigationPositionSubject$ = new BehaviorSubject({ x: 0, y: 0 });
|
|
5637
5799
|
const viewportStateSubject = new BehaviorSubject(`free`);
|
|
5800
|
+
const settings = createSettings(inputSettings);
|
|
5638
5801
|
const context = createContext(settings);
|
|
5639
|
-
const spineItemManager = createSpineItemManager({ context });
|
|
5802
|
+
const spineItemManager = createSpineItemManager({ context, settings });
|
|
5640
5803
|
const pagination = createPagination({ context, spineItemManager });
|
|
5641
|
-
const
|
|
5642
|
-
const
|
|
5804
|
+
const elementSubject$ = new BehaviorSubject(void 0);
|
|
5805
|
+
const element$ = elementSubject$.pipe(filter(isDefined));
|
|
5806
|
+
const iframeEventBridgeElement$ = new BehaviorSubject(void 0);
|
|
5643
5807
|
const spineItemLocator = createLocationResolver$1({ context });
|
|
5644
5808
|
const spineLocator = createLocationResolver({
|
|
5645
5809
|
context,
|
|
5646
5810
|
spineItemManager,
|
|
5647
|
-
spineItemLocator
|
|
5811
|
+
spineItemLocator,
|
|
5812
|
+
settings
|
|
5648
5813
|
});
|
|
5649
5814
|
const cfiLocator = createCfiLocator({
|
|
5650
5815
|
spineItemManager,
|
|
@@ -5653,9 +5818,10 @@ const createReader = ({ containerElement, hooks: initialHooks, ...settings }) =>
|
|
|
5653
5818
|
});
|
|
5654
5819
|
const navigation$ = navigationSubject.asObservable();
|
|
5655
5820
|
const spine = createSpine({
|
|
5656
|
-
|
|
5657
|
-
iframeEventBridgeElement
|
|
5821
|
+
element$,
|
|
5822
|
+
iframeEventBridgeElement$,
|
|
5658
5823
|
context,
|
|
5824
|
+
settings,
|
|
5659
5825
|
pagination,
|
|
5660
5826
|
spineItemManager,
|
|
5661
5827
|
hooks$: hooksSubject$,
|
|
@@ -5671,22 +5837,26 @@ const createReader = ({ containerElement, hooks: initialHooks, ...settings }) =>
|
|
|
5671
5837
|
context,
|
|
5672
5838
|
pagination,
|
|
5673
5839
|
spineItemManager,
|
|
5674
|
-
parentElement
|
|
5840
|
+
parentElement$: elementSubject$,
|
|
5675
5841
|
cfiLocator,
|
|
5676
5842
|
spineLocator,
|
|
5677
5843
|
hooks$: hooksSubject$,
|
|
5678
|
-
spine
|
|
5844
|
+
spine,
|
|
5845
|
+
settings
|
|
5679
5846
|
});
|
|
5680
|
-
containerElement.appendChild(element);
|
|
5681
|
-
element.appendChild(iframeEventBridgeElement);
|
|
5682
5847
|
viewportNavigator.$.state$.subscribe(viewportStateSubject);
|
|
5683
5848
|
viewportNavigator.$.navigation$.subscribe(navigationSubject);
|
|
5684
5849
|
viewportNavigator.$.navigationAdjustedAfterLayout$.subscribe(navigationAdjustedSubject);
|
|
5685
5850
|
viewportNavigator.$.currentNavigationPosition$.subscribe(currentNavigationPositionSubject$);
|
|
5686
5851
|
const layout = () => {
|
|
5852
|
+
var _a;
|
|
5853
|
+
const containerElement = (_a = elementSubject$.getValue()) == null ? void 0 : _a.parentElement;
|
|
5854
|
+
const element = elementSubject$.getValue();
|
|
5855
|
+
if (!element || !containerElement)
|
|
5856
|
+
throw new Error("Invalid element");
|
|
5687
5857
|
const dimensions = {
|
|
5688
|
-
width: containerElement.offsetWidth,
|
|
5689
|
-
height: containerElement.offsetHeight
|
|
5858
|
+
width: containerElement == null ? void 0 : containerElement.offsetWidth,
|
|
5859
|
+
height: containerElement == null ? void 0 : containerElement.offsetHeight
|
|
5690
5860
|
};
|
|
5691
5861
|
const margin = 0;
|
|
5692
5862
|
const marginTop = 0;
|
|
@@ -5706,12 +5876,21 @@ const createReader = ({ containerElement, hooks: initialHooks, ...settings }) =>
|
|
|
5706
5876
|
});
|
|
5707
5877
|
viewportNavigator.layout();
|
|
5708
5878
|
};
|
|
5709
|
-
const load = (manifest, loadOptions
|
|
5879
|
+
const load = (manifest, loadOptions) => {
|
|
5880
|
+
var _a;
|
|
5710
5881
|
if (context.getManifest()) {
|
|
5711
5882
|
Report.warn(`loading a new book is not supported yet`);
|
|
5712
5883
|
return;
|
|
5713
5884
|
}
|
|
5714
5885
|
Report.log(`load`, { manifest, loadOptions });
|
|
5886
|
+
const element = createWrapperElement(loadOptions.containerElement);
|
|
5887
|
+
const iframeEventBridgeElement = createIframeEventBridgeElement(loadOptions.containerElement);
|
|
5888
|
+
if (loadOptions.containerElement !== ((_a = elementSubject$.getValue()) == null ? void 0 : _a.parentElement)) {
|
|
5889
|
+
elementSubject$.next(element);
|
|
5890
|
+
iframeEventBridgeElement$.next(iframeEventBridgeElement);
|
|
5891
|
+
loadOptions.containerElement.appendChild(element);
|
|
5892
|
+
element.appendChild(iframeEventBridgeElement);
|
|
5893
|
+
}
|
|
5715
5894
|
context.load(manifest, loadOptions);
|
|
5716
5895
|
layout();
|
|
5717
5896
|
if (!loadOptions.cfi) {
|
|
@@ -5719,14 +5898,10 @@ const createReader = ({ containerElement, hooks: initialHooks, ...settings }) =>
|
|
|
5719
5898
|
} else {
|
|
5720
5899
|
viewportNavigator.goToCfi(loadOptions.cfi, { animate: false });
|
|
5721
5900
|
}
|
|
5722
|
-
readySubject$.next();
|
|
5723
5901
|
};
|
|
5724
5902
|
const registerHook = (name, fn) => {
|
|
5725
5903
|
hooksSubject$.next([...hooksSubject$.getValue(), { name, fn }]);
|
|
5726
5904
|
};
|
|
5727
|
-
const manipulateContainer = (cb) => {
|
|
5728
|
-
cb(element);
|
|
5729
|
-
};
|
|
5730
5905
|
spine.$.$.pipe(
|
|
5731
5906
|
tap((event) => {
|
|
5732
5907
|
if (event.type === `onSelectionChange`) {
|
|
@@ -5741,45 +5916,42 @@ const createReader = ({ containerElement, hooks: initialHooks, ...settings }) =>
|
|
|
5741
5916
|
}),
|
|
5742
5917
|
takeUntil$1(context.$.destroy$)
|
|
5743
5918
|
).subscribe();
|
|
5744
|
-
merge(context.$.
|
|
5745
|
-
|
|
5746
|
-
withLatestFrom(context.$.
|
|
5747
|
-
map$1(([, hasVerticalWriting]) => {
|
|
5748
|
-
const settings2 = context.getSettings();
|
|
5919
|
+
merge(context.$.state$, settings.$.settings$).pipe(
|
|
5920
|
+
map$1(() => void 0),
|
|
5921
|
+
withLatestFrom(context.$.state$),
|
|
5922
|
+
map$1(([, { hasVerticalWriting }]) => {
|
|
5749
5923
|
const manifest = context.getManifest();
|
|
5750
5924
|
return {
|
|
5751
5925
|
hasVerticalWriting,
|
|
5752
5926
|
renditionFlow: manifest == null ? void 0 : manifest.renditionFlow,
|
|
5753
5927
|
renditionLayout: manifest == null ? void 0 : manifest.renditionLayout,
|
|
5754
|
-
computedPageTurnMode:
|
|
5928
|
+
computedPageTurnMode: settings.getSettings().computedPageTurnMode
|
|
5755
5929
|
};
|
|
5756
5930
|
}),
|
|
5757
5931
|
distinctUntilChanged(isShallowEqual),
|
|
5758
5932
|
map$1(
|
|
5759
|
-
({
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
supportedPageTurnAnimation: renditionFlow === `scrolled-continuous` || computedPageTurnMode === `scrollable` ? [`none`] : hasVerticalWriting ? [`fade`, `none`] : [`fade`, `none`, `slide`],
|
|
5768
|
-
supportedPageTurnDirection: computedPageTurnMode === `scrollable` ? [`vertical`] : renditionLayout === `reflowable` ? [`horizontal`] : [`horizontal`, `vertical`]
|
|
5769
|
-
})
|
|
5933
|
+
({ hasVerticalWriting, renditionFlow, renditionLayout, computedPageTurnMode }) => {
|
|
5934
|
+
return {
|
|
5935
|
+
...stateSubject$.value,
|
|
5936
|
+
supportedPageTurnMode: renditionFlow === `scrolled-continuous` ? [`scrollable`] : !context.areAllItemsPrePaginated() ? [`controlled`] : [`controlled`, `scrollable`],
|
|
5937
|
+
supportedPageTurnAnimation: renditionFlow === `scrolled-continuous` || computedPageTurnMode === `scrollable` ? [`none`] : hasVerticalWriting ? [`fade`, `none`] : [`fade`, `none`, `slide`],
|
|
5938
|
+
supportedPageTurnDirection: computedPageTurnMode === `scrollable` ? [`vertical`] : renditionLayout === `reflowable` ? [`horizontal`] : [`horizontal`, `vertical`]
|
|
5939
|
+
};
|
|
5940
|
+
}
|
|
5770
5941
|
),
|
|
5771
5942
|
takeUntil$1(destroy$)
|
|
5772
5943
|
).subscribe(stateSubject$);
|
|
5773
5944
|
const destroy = () => {
|
|
5945
|
+
var _a, _b;
|
|
5946
|
+
settings.destroy();
|
|
5774
5947
|
hooksSubject$.next([]);
|
|
5775
5948
|
hooksSubject$.complete();
|
|
5776
5949
|
pagination.destroy();
|
|
5777
5950
|
context.destroy();
|
|
5778
5951
|
viewportNavigator.destroy();
|
|
5779
5952
|
spine.destroy();
|
|
5780
|
-
|
|
5781
|
-
iframeEventBridgeElement.remove();
|
|
5782
|
-
readySubject$.complete();
|
|
5953
|
+
(_a = elementSubject$.getValue()) == null ? void 0 : _a.remove();
|
|
5954
|
+
(_b = iframeEventBridgeElement$.getValue()) == null ? void 0 : _b.remove();
|
|
5783
5955
|
stateSubject$.complete();
|
|
5784
5956
|
selectionSubject$.complete();
|
|
5785
5957
|
destroy$.next();
|
|
@@ -5792,7 +5964,6 @@ const createReader = ({ containerElement, hooks: initialHooks, ...settings }) =>
|
|
|
5792
5964
|
viewportNavigator,
|
|
5793
5965
|
manipulateSpineItems: spine.manipulateSpineItems,
|
|
5794
5966
|
manipulateSpineItem: spine.manipulateSpineItem,
|
|
5795
|
-
manipulateContainer,
|
|
5796
5967
|
moveTo: viewportNavigator.moveTo,
|
|
5797
5968
|
turnLeft: viewportNavigator.turnLeft,
|
|
5798
5969
|
turnRight: viewportNavigator.turnRight,
|
|
@@ -5817,23 +5988,23 @@ const createReader = ({ containerElement, hooks: initialHooks, ...settings }) =>
|
|
|
5817
5988
|
layout,
|
|
5818
5989
|
load,
|
|
5819
5990
|
destroy,
|
|
5820
|
-
setSettings: context.setSettings,
|
|
5821
|
-
settings$: context.$.settings$,
|
|
5822
|
-
/**
|
|
5823
|
-
* @important
|
|
5824
|
-
* BehaviorSubject
|
|
5825
|
-
*/
|
|
5826
|
-
pagination$: pagination.$.info$,
|
|
5827
5991
|
spineItems$: spine.$.spineItems$,
|
|
5992
|
+
context$: context.$.state$,
|
|
5993
|
+
pagination,
|
|
5994
|
+
settings: {
|
|
5995
|
+
settings$: settings.$.settings$,
|
|
5996
|
+
getSettings: settings.getSettings,
|
|
5997
|
+
setSettings: (data) => settings.setSettings(data, context.getState())
|
|
5998
|
+
},
|
|
5828
5999
|
$: {
|
|
5829
6000
|
state$: stateSubject$.asObservable(),
|
|
5830
6001
|
/**
|
|
5831
|
-
* Dispatched when the reader has loaded a book and is
|
|
6002
|
+
* Dispatched when the reader has loaded a book and is rendering a book.
|
|
5832
6003
|
* Using navigation API and getting information about current content will
|
|
5833
6004
|
* have an effect.
|
|
5834
6005
|
* It can typically be used to hide a loading indicator.
|
|
5835
6006
|
*/
|
|
5836
|
-
|
|
6007
|
+
loadStatus$: context.$.manifest$.pipe(map$1((manifest) => manifest ? "ready" : "idle")),
|
|
5837
6008
|
/**
|
|
5838
6009
|
* Dispatched when a change in selection happens
|
|
5839
6010
|
*/
|
|
@@ -6036,7 +6207,7 @@ const createResourcesManager = (context) => {
|
|
|
6036
6207
|
}),
|
|
6037
6208
|
takeUntil$1(context.$.destroy$)
|
|
6038
6209
|
).subscribe();
|
|
6039
|
-
const onLoad$ = context.$.
|
|
6210
|
+
const onLoad$ = context.$.manifest$.pipe(
|
|
6040
6211
|
tap(() => {
|
|
6041
6212
|
uniqueID = Date.now().toString();
|
|
6042
6213
|
})
|
|
@@ -6188,9 +6359,9 @@ const progressionEnhancer = (next) => (options) => {
|
|
|
6188
6359
|
totalProgress = getTotalProgressFromPercentages(estimateBeforeThisItem, currentItemWeight, progressWithinThisItem);
|
|
6189
6360
|
}
|
|
6190
6361
|
if (currentSpineIndex === readingOrderLength - 1 && pageIndex === numberOfPages - 1 && totalProgress > 0.99) {
|
|
6191
|
-
return
|
|
6362
|
+
return 100;
|
|
6192
6363
|
}
|
|
6193
|
-
return totalProgress;
|
|
6364
|
+
return totalProgress * 100;
|
|
6194
6365
|
};
|
|
6195
6366
|
const getTotalProgressFromPercentages = (estimateBeforeThisItem, currentItemWeight, progressWithinThisItem) => {
|
|
6196
6367
|
return estimateBeforeThisItem + currentItemWeight * progressWithinThisItem;
|
|
@@ -6198,7 +6369,7 @@ const progressionEnhancer = (next) => (options) => {
|
|
|
6198
6369
|
const getScrollPercentageWithinItem = (context, currentPosition, currentItem) => {
|
|
6199
6370
|
const { height, width } = currentItem.getElementDimensions();
|
|
6200
6371
|
const { top, left } = reader.getAbsolutePositionOf(currentItem);
|
|
6201
|
-
if (
|
|
6372
|
+
if (reader.settings.getSettings().computedPageTurnDirection === `vertical`) {
|
|
6202
6373
|
return Math.max(0, Math.min(1, (currentPosition.y - top + context.getVisibleAreaRect().height) / height));
|
|
6203
6374
|
} else {
|
|
6204
6375
|
return Math.max(0, Math.min(1, (currentPosition.x - left + context.getVisibleAreaRect().width) / width));
|
|
@@ -6388,26 +6559,34 @@ const defaultLoadingElementCreate = ({ container, item }) => {
|
|
|
6388
6559
|
container.appendChild(detailsElement);
|
|
6389
6560
|
return container;
|
|
6390
6561
|
};
|
|
6562
|
+
const publicApiEnhancer = (next) => {
|
|
6563
|
+
return (options) => {
|
|
6564
|
+
const reader = next(options);
|
|
6565
|
+
return reader;
|
|
6566
|
+
};
|
|
6567
|
+
};
|
|
6391
6568
|
const createReaderWithEnhancers = (
|
|
6392
6569
|
//__
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6570
|
+
publicApiEnhancer(
|
|
6571
|
+
loadingEnhancer(
|
|
6572
|
+
webkitEnhancer(
|
|
6573
|
+
fontsEnhancer(
|
|
6574
|
+
linksEnhancer(
|
|
6575
|
+
accessibilityEnhancer(
|
|
6576
|
+
resourcesEnhancer(
|
|
6577
|
+
utilsEnhancer(
|
|
6578
|
+
layoutEnhancer(
|
|
6579
|
+
zoomEnhancer(
|
|
6580
|
+
mediaEnhancer(
|
|
6581
|
+
chromeEnhancer(
|
|
6582
|
+
navigationEnhancer(
|
|
6583
|
+
themeEnhancer(
|
|
6584
|
+
hotkeysEnhancer(
|
|
6585
|
+
paginationEnhancer(
|
|
6586
|
+
progressionEnhancer(
|
|
6587
|
+
// __
|
|
6588
|
+
createReader
|
|
6589
|
+
)
|
|
6411
6590
|
)
|
|
6412
6591
|
)
|
|
6413
6592
|
)
|
|
@@ -6431,4 +6610,4 @@ export {
|
|
|
6431
6610
|
groupBy,
|
|
6432
6611
|
isShallowEqual
|
|
6433
6612
|
};
|
|
6434
|
-
//# sourceMappingURL=
|
|
6613
|
+
//# sourceMappingURL=index.js.map
|