@prose-reader/core 1.70.0 → 1.71.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/enhancers/navigation/state.d.ts +2 -0
- package/dist/index.js +37 -16
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +37 -16
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +3 -3
|
@@ -2,6 +2,8 @@ import { Reader } from '../../reader';
|
|
|
2
2
|
|
|
3
3
|
export type State = ReturnType<typeof observeState>;
|
|
4
4
|
export declare const observeState: (reader: Reader) => import('rxjs').Observable<{
|
|
5
|
+
canTurnLeft: boolean;
|
|
6
|
+
canTurnRight: boolean;
|
|
5
7
|
canGoTopSpineItem: boolean;
|
|
6
8
|
canGoBottomSpineItem: boolean;
|
|
7
9
|
canGoLeftSpineItem: boolean;
|
package/dist/index.js
CHANGED
|
@@ -1062,19 +1062,29 @@ class PanNavigator {
|
|
|
1062
1062
|
const observeState = (reader) => {
|
|
1063
1063
|
return reader.pagination.pagination$.pipe(
|
|
1064
1064
|
withLatestFrom(reader.context.manifest$, reader.settings.settings$),
|
|
1065
|
-
map$1(
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1065
|
+
map$1(
|
|
1066
|
+
([
|
|
1067
|
+
paginationInfo,
|
|
1068
|
+
{ spineItems, readingDirection },
|
|
1069
|
+
{ computedPageTurnDirection }
|
|
1070
|
+
]) => {
|
|
1071
|
+
const numberOfSpineItems = spineItems.length ?? 0;
|
|
1072
|
+
const isAtAbsoluteBeginning = paginationInfo.beginSpineItemIndex === 0;
|
|
1073
|
+
const isAtAbsoluteEnd = paginationInfo.endSpineItemIndex === Math.max(numberOfSpineItems - 1, 0);
|
|
1074
|
+
const isAtEndSpineItem = paginationInfo.endSpineItemIndex === Math.max(numberOfSpineItems - 1, 0);
|
|
1075
|
+
const isAtBeginSpineItem = paginationInfo.beginSpineItemIndex === 0;
|
|
1076
|
+
const isAtBeginFirstPage = paginationInfo.beginPageIndexInSpineItem === 0;
|
|
1077
|
+
const isAtEndLastPage = paginationInfo.endPageIndexInSpineItem === paginationInfo.endNumberOfPagesInSpineItem - 1;
|
|
1078
|
+
return {
|
|
1079
|
+
canTurnLeft: computedPageTurnDirection === "vertical" ? false : !isAtBeginFirstPage,
|
|
1080
|
+
canTurnRight: computedPageTurnDirection === "vertical" ? false : !isAtEndLastPage,
|
|
1081
|
+
canGoTopSpineItem: computedPageTurnDirection === "vertical" && !isAtAbsoluteBeginning,
|
|
1082
|
+
canGoBottomSpineItem: computedPageTurnDirection === "vertical" && !isAtAbsoluteEnd,
|
|
1083
|
+
canGoLeftSpineItem: computedPageTurnDirection !== "vertical" && (readingDirection === "ltr" && !isAtAbsoluteBeginning || readingDirection === "rtl" && !isAtEndSpineItem),
|
|
1084
|
+
canGoRightSpineItem: computedPageTurnDirection !== "vertical" && (readingDirection === "ltr" && !isAtAbsoluteEnd || readingDirection === "rtl" && !isAtBeginSpineItem)
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
),
|
|
1078
1088
|
distinctUntilChanged$1(isShallowEqual)
|
|
1079
1089
|
);
|
|
1080
1090
|
};
|
|
@@ -4438,7 +4448,7 @@ class InternalNavigator extends DestroyableClass {
|
|
|
4438
4448
|
map$1(
|
|
4439
4449
|
() => ({
|
|
4440
4450
|
...navigation,
|
|
4441
|
-
animation: "
|
|
4451
|
+
animation: "snap"
|
|
4442
4452
|
})
|
|
4443
4453
|
),
|
|
4444
4454
|
finalize(() => {
|
|
@@ -4805,7 +4815,7 @@ class ReaderSettingsManager extends SettingsManager3 {
|
|
|
4805
4815
|
pageTurnMode: `controlled`,
|
|
4806
4816
|
snapAnimationDuration: 300,
|
|
4807
4817
|
navigationSnapThreshold: 0.3,
|
|
4808
|
-
numberOfAdjacentSpineItemToPreLoad:
|
|
4818
|
+
numberOfAdjacentSpineItemToPreLoad: 2
|
|
4809
4819
|
};
|
|
4810
4820
|
}
|
|
4811
4821
|
}
|
|
@@ -6914,7 +6924,18 @@ class SpineItemsLoader extends DestroyableClass {
|
|
|
6914
6924
|
const layoutHasChanged$ = spineItemsManager.layout$.pipe(
|
|
6915
6925
|
filter$1((hasChanged) => hasChanged)
|
|
6916
6926
|
);
|
|
6917
|
-
const
|
|
6927
|
+
const numberOfAdjacentSpineItemToPreLoad$ = settings.settings$.pipe(
|
|
6928
|
+
map$1(
|
|
6929
|
+
({ numberOfAdjacentSpineItemToPreLoad }) => numberOfAdjacentSpineItemToPreLoad
|
|
6930
|
+
),
|
|
6931
|
+
skip$1(1),
|
|
6932
|
+
distinctUntilChanged$1()
|
|
6933
|
+
);
|
|
6934
|
+
const loadSpineItems$ = merge(
|
|
6935
|
+
navigationUpdate$,
|
|
6936
|
+
layoutHasChanged$,
|
|
6937
|
+
numberOfAdjacentSpineItemToPreLoad$
|
|
6938
|
+
).pipe(
|
|
6918
6939
|
// this can be changed by whatever we want and SHOULD not break navigation.
|
|
6919
6940
|
// Ideally loading faster is better but loading too close to user navigating can
|
|
6920
6941
|
// be dangerous.
|