@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
package/dist/index.umd.cjs
CHANGED
|
@@ -1063,19 +1063,29 @@
|
|
|
1063
1063
|
const observeState = (reader) => {
|
|
1064
1064
|
return reader.pagination.pagination$.pipe(
|
|
1065
1065
|
rxjs.withLatestFrom(reader.context.manifest$, reader.settings.settings$),
|
|
1066
|
-
rxjs.map(
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1066
|
+
rxjs.map(
|
|
1067
|
+
([
|
|
1068
|
+
paginationInfo,
|
|
1069
|
+
{ spineItems, readingDirection },
|
|
1070
|
+
{ computedPageTurnDirection }
|
|
1071
|
+
]) => {
|
|
1072
|
+
const numberOfSpineItems = spineItems.length ?? 0;
|
|
1073
|
+
const isAtAbsoluteBeginning = paginationInfo.beginSpineItemIndex === 0;
|
|
1074
|
+
const isAtAbsoluteEnd = paginationInfo.endSpineItemIndex === Math.max(numberOfSpineItems - 1, 0);
|
|
1075
|
+
const isAtEndSpineItem = paginationInfo.endSpineItemIndex === Math.max(numberOfSpineItems - 1, 0);
|
|
1076
|
+
const isAtBeginSpineItem = paginationInfo.beginSpineItemIndex === 0;
|
|
1077
|
+
const isAtBeginFirstPage = paginationInfo.beginPageIndexInSpineItem === 0;
|
|
1078
|
+
const isAtEndLastPage = paginationInfo.endPageIndexInSpineItem === paginationInfo.endNumberOfPagesInSpineItem - 1;
|
|
1079
|
+
return {
|
|
1080
|
+
canTurnLeft: computedPageTurnDirection === "vertical" ? false : !isAtBeginFirstPage,
|
|
1081
|
+
canTurnRight: computedPageTurnDirection === "vertical" ? false : !isAtEndLastPage,
|
|
1082
|
+
canGoTopSpineItem: computedPageTurnDirection === "vertical" && !isAtAbsoluteBeginning,
|
|
1083
|
+
canGoBottomSpineItem: computedPageTurnDirection === "vertical" && !isAtAbsoluteEnd,
|
|
1084
|
+
canGoLeftSpineItem: computedPageTurnDirection !== "vertical" && (readingDirection === "ltr" && !isAtAbsoluteBeginning || readingDirection === "rtl" && !isAtEndSpineItem),
|
|
1085
|
+
canGoRightSpineItem: computedPageTurnDirection !== "vertical" && (readingDirection === "ltr" && !isAtAbsoluteEnd || readingDirection === "rtl" && !isAtBeginSpineItem)
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
),
|
|
1079
1089
|
rxjs.distinctUntilChanged(isShallowEqual)
|
|
1080
1090
|
);
|
|
1081
1091
|
};
|
|
@@ -4439,7 +4449,7 @@
|
|
|
4439
4449
|
rxjs.map(
|
|
4440
4450
|
() => ({
|
|
4441
4451
|
...navigation,
|
|
4442
|
-
animation: "
|
|
4452
|
+
animation: "snap"
|
|
4443
4453
|
})
|
|
4444
4454
|
),
|
|
4445
4455
|
rxjs.finalize(() => {
|
|
@@ -4806,7 +4816,7 @@
|
|
|
4806
4816
|
pageTurnMode: `controlled`,
|
|
4807
4817
|
snapAnimationDuration: 300,
|
|
4808
4818
|
navigationSnapThreshold: 0.3,
|
|
4809
|
-
numberOfAdjacentSpineItemToPreLoad:
|
|
4819
|
+
numberOfAdjacentSpineItemToPreLoad: 2
|
|
4810
4820
|
};
|
|
4811
4821
|
}
|
|
4812
4822
|
}
|
|
@@ -6915,7 +6925,18 @@
|
|
|
6915
6925
|
const layoutHasChanged$ = spineItemsManager.layout$.pipe(
|
|
6916
6926
|
rxjs.filter((hasChanged) => hasChanged)
|
|
6917
6927
|
);
|
|
6918
|
-
const
|
|
6928
|
+
const numberOfAdjacentSpineItemToPreLoad$ = settings.settings$.pipe(
|
|
6929
|
+
rxjs.map(
|
|
6930
|
+
({ numberOfAdjacentSpineItemToPreLoad }) => numberOfAdjacentSpineItemToPreLoad
|
|
6931
|
+
),
|
|
6932
|
+
rxjs.skip(1),
|
|
6933
|
+
rxjs.distinctUntilChanged()
|
|
6934
|
+
);
|
|
6935
|
+
const loadSpineItems$ = rxjs.merge(
|
|
6936
|
+
navigationUpdate$,
|
|
6937
|
+
layoutHasChanged$,
|
|
6938
|
+
numberOfAdjacentSpineItemToPreLoad$
|
|
6939
|
+
).pipe(
|
|
6919
6940
|
// this can be changed by whatever we want and SHOULD not break navigation.
|
|
6920
6941
|
// Ideally loading faster is better but loading too close to user navigating can
|
|
6921
6942
|
// be dangerous.
|