@prose-reader/core 1.195.0 → 1.196.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.js +106 -90
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +106 -90
- package/dist/index.umd.cjs.map +1 -1
- package/dist/navigation/tests/SpineItemsManagerMock.d.ts +1 -1
- package/dist/navigation/tests/utils.d.ts +1 -1
- package/dist/spine/SpineItemsManager.d.ts +3 -3
- package/dist/spine/SpineLayout.d.ts +6 -26
- package/dist/spine/layout/convertViewportPositionToLayoutPosition.d.ts +2 -2
- package/dist/spine/layout/layoutItem.d.ts +2 -0
- package/dist/spine/layout/types.d.ts +11 -0
- package/dist/spineItem/SpineItem.d.ts +1 -14
- package/dist/spineItem/SpineItemLayout.d.ts +1 -7
- package/package.json +3 -3
package/dist/index.umd.cjs
CHANGED
|
@@ -3308,8 +3308,8 @@
|
|
|
3308
3308
|
};
|
|
3309
3309
|
const getScrollPercentageWithinItem = (reader, currentPosition, currentItem) => {
|
|
3310
3310
|
const context = reader.context;
|
|
3311
|
-
const { height, width } = currentItem.
|
|
3312
|
-
const { top, left } = reader.spine.spineLayout.
|
|
3311
|
+
const { height, width } = currentItem.layout.layoutInfo;
|
|
3312
|
+
const { top, left } = reader.spine.spineLayout.getSpineItemRelativeLayoutInfo(currentItem);
|
|
3313
3313
|
if (reader.settings.values.computedPageTurnDirection === `vertical`) {
|
|
3314
3314
|
return Math.max(
|
|
3315
3315
|
0,
|
|
@@ -3372,7 +3372,7 @@
|
|
|
3372
3372
|
);
|
|
3373
3373
|
};
|
|
3374
3374
|
const getNumberOfPagesForAllSpineItems = (reader) => reader.spineItemsManager.items.map((item) => {
|
|
3375
|
-
const { height, width } = item.
|
|
3375
|
+
const { height, width } = item.layout.layoutInfo;
|
|
3376
3376
|
return reader.spine.spineItemLocator.getSpineItemNumberOfPages({
|
|
3377
3377
|
isUsingVerticalWriting: !!item.isUsingVerticalWriting(),
|
|
3378
3378
|
itemHeight: height,
|
|
@@ -5572,7 +5572,7 @@
|
|
|
5572
5572
|
const range = node ? getRangeFromNode(node, offset) : void 0;
|
|
5573
5573
|
offsetOfNodeInSpineItem = (range == null ? void 0 : range.getBoundingClientRect().x) || offsetOfNodeInSpineItem;
|
|
5574
5574
|
}
|
|
5575
|
-
const spineItemWidth = ((_a = spineItem.
|
|
5575
|
+
const spineItemWidth = ((_a = spineItem.layout.layoutInfo) == null ? void 0 : _a.width) || 0;
|
|
5576
5576
|
const pageWidth = context.getPageSize().width;
|
|
5577
5577
|
if (offsetOfNodeInSpineItem !== void 0) {
|
|
5578
5578
|
const val = getClosestValidOffsetFromApproximateOffsetInPages(
|
|
@@ -5592,7 +5592,7 @@
|
|
|
5592
5592
|
frame.contentWindow.document.body !== null) {
|
|
5593
5593
|
const { x: left, y: top } = getSpineItemPositionFromPageIndex({
|
|
5594
5594
|
pageIndex,
|
|
5595
|
-
itemLayout: spineItem.
|
|
5595
|
+
itemLayout: spineItem.layout.layoutInfo,
|
|
5596
5596
|
context,
|
|
5597
5597
|
isUsingVerticalWriting: !!spineItem.isUsingVerticalWriting()
|
|
5598
5598
|
});
|
|
@@ -5611,7 +5611,7 @@
|
|
|
5611
5611
|
return void 0;
|
|
5612
5612
|
};
|
|
5613
5613
|
const getSpineItemClosestPositionFromUnsafePosition = (unsafePosition, spineItem) => {
|
|
5614
|
-
const { width, height } = spineItem.
|
|
5614
|
+
const { width, height } = spineItem.layout.layoutInfo;
|
|
5615
5615
|
const adjustedPosition = {
|
|
5616
5616
|
x: getClosestValidOffsetFromApproximateOffsetInPages(
|
|
5617
5617
|
unsafePosition.x,
|
|
@@ -5628,7 +5628,7 @@
|
|
|
5628
5628
|
};
|
|
5629
5629
|
const getSpineItemPageIndexFromNode = (node, offset, spineItem) => {
|
|
5630
5630
|
const position = getSpineItemPositionFromNode(node, offset, spineItem);
|
|
5631
|
-
const { height, width } = spineItem.
|
|
5631
|
+
const { height, width } = spineItem.layout.layoutInfo;
|
|
5632
5632
|
return position ? getSpineItemPageIndexFromPosition({
|
|
5633
5633
|
isUsingVerticalWriting: !!spineItem.isUsingVerticalWriting(),
|
|
5634
5634
|
position,
|
|
@@ -5666,7 +5666,7 @@
|
|
|
5666
5666
|
context,
|
|
5667
5667
|
isUsingVerticalWriting: !!item.isUsingVerticalWriting(),
|
|
5668
5668
|
settings,
|
|
5669
|
-
itemLayout: item.
|
|
5669
|
+
itemLayout: item.layout.layoutInfo
|
|
5670
5670
|
});
|
|
5671
5671
|
},
|
|
5672
5672
|
getSpineItemNumberOfPages: (params) => getSpineItemNumberOfPages({
|
|
@@ -5682,7 +5682,7 @@
|
|
|
5682
5682
|
}) => {
|
|
5683
5683
|
const spineItemLocator = createSpineItemLocator({ context, settings });
|
|
5684
5684
|
const getNavigationForLastPage = (spineItem) => {
|
|
5685
|
-
const { height, width } = spineItem.
|
|
5685
|
+
const { height, width } = spineItem.layout.layoutInfo;
|
|
5686
5686
|
const numberOfPages = spineItemLocator.getSpineItemNumberOfPages({
|
|
5687
5687
|
isUsingVerticalWriting: !!spineItem.isUsingVerticalWriting(),
|
|
5688
5688
|
itemHeight: height,
|
|
@@ -5691,7 +5691,7 @@
|
|
|
5691
5691
|
return spineItemLocator.getSpineItemPositionFromPageIndex({
|
|
5692
5692
|
pageIndex: numberOfPages - 1,
|
|
5693
5693
|
isUsingVerticalWriting: !!spineItem.isUsingVerticalWriting(),
|
|
5694
|
-
itemLayout: spineItem.
|
|
5694
|
+
itemLayout: spineItem.layout.layoutInfo
|
|
5695
5695
|
});
|
|
5696
5696
|
};
|
|
5697
5697
|
const getNavigationFromNode = (spineItem, node, offset) => {
|
|
@@ -5735,7 +5735,7 @@
|
|
|
5735
5735
|
const lastSpineItem = spineItemsManager.get(
|
|
5736
5736
|
spineItemsManager.items.length - 1
|
|
5737
5737
|
);
|
|
5738
|
-
const distanceOfLastSpineItem = spineLayout.
|
|
5738
|
+
const distanceOfLastSpineItem = spineLayout.getSpineItemRelativeLayoutInfo(
|
|
5739
5739
|
lastSpineItem || 0
|
|
5740
5740
|
);
|
|
5741
5741
|
const maximumYOffset = distanceOfLastSpineItem.bottom - pageSizeHeight;
|
|
@@ -5758,7 +5758,7 @@
|
|
|
5758
5758
|
context
|
|
5759
5759
|
}) => {
|
|
5760
5760
|
var _a;
|
|
5761
|
-
const itemWidth = ((_a = spineItem.
|
|
5761
|
+
const itemWidth = ((_a = spineItem.layout.layoutInfo) == null ? void 0 : _a.width) || 0;
|
|
5762
5762
|
const pageWidth = context.getPageSize().width;
|
|
5763
5763
|
const anchorElementBoundingRect = spineItem.getBoundingRectOfElementFromSelector(anchor);
|
|
5764
5764
|
const offsetOfAnchor = (anchorElementBoundingRect == null ? void 0 : anchorElementBoundingRect.x) || 0;
|
|
@@ -5917,7 +5917,7 @@
|
|
|
5917
5917
|
const spineItemNavigation = spineLocator.spineItemLocator.getSpineItemPositionFromPageIndex({
|
|
5918
5918
|
pageIndex,
|
|
5919
5919
|
isUsingVerticalWriting: !!spineItem.isUsingVerticalWriting(),
|
|
5920
|
-
itemLayout: spineItem.
|
|
5920
|
+
itemLayout: spineItem.layout.layoutInfo
|
|
5921
5921
|
});
|
|
5922
5922
|
const readingOffset = spineLocator.getSpinePositionFromSpineItemPosition({
|
|
5923
5923
|
spineItemPosition: spineItemNavigation,
|
|
@@ -6628,9 +6628,7 @@
|
|
|
6628
6628
|
const withSpineItemLayoutInfo = ({ spine }) => (stream) => {
|
|
6629
6629
|
return stream.pipe(
|
|
6630
6630
|
rxjs.switchMap(({ navigation, ...rest }) => {
|
|
6631
|
-
const spineItemDimensions = spine.spineLayout.
|
|
6632
|
-
navigation.spineItem
|
|
6633
|
-
);
|
|
6631
|
+
const spineItemDimensions = spine.spineLayout.getSpineItemRelativeLayoutInfo(navigation.spineItem);
|
|
6634
6632
|
const spineItem = spine.spineItemsManager.get(navigation.spineItem);
|
|
6635
6633
|
return ((spineItem == null ? void 0 : spineItem.isReady$) ?? rxjs.of(false)).pipe(
|
|
6636
6634
|
rxjs.first(),
|
|
@@ -6684,7 +6682,7 @@
|
|
|
6684
6682
|
const positionInSpineItem = spineLocator.spineItemLocator.getSpineItemPositionFromPageIndex({
|
|
6685
6683
|
pageIndex: beginPageIndexForDirection,
|
|
6686
6684
|
isUsingVerticalWriting: !!spineItem.isUsingVerticalWriting(),
|
|
6687
|
-
itemLayout: spineItem.
|
|
6685
|
+
itemLayout: spineItem.layout.layoutInfo
|
|
6688
6686
|
});
|
|
6689
6687
|
return positionInSpineItem;
|
|
6690
6688
|
}
|
|
@@ -6745,7 +6743,7 @@
|
|
|
6745
6743
|
rxjs.first(),
|
|
6746
6744
|
rxjs.map((isReady) => {
|
|
6747
6745
|
var _a, _b;
|
|
6748
|
-
const spineItemAbsolutePosition = spineLayout.
|
|
6746
|
+
const spineItemAbsolutePosition = spineLayout.getSpineItemRelativeLayoutInfo(spineItem);
|
|
6749
6747
|
const isPositionWithinSpineItem = spineLocator.isPositionWithinSpineItem(
|
|
6750
6748
|
navigation.position,
|
|
6751
6749
|
spineItem
|
|
@@ -6816,7 +6814,7 @@
|
|
|
6816
6814
|
const { spineItem } = navigation;
|
|
6817
6815
|
const foundSpineItem = spineItemsManager.get(spineItem);
|
|
6818
6816
|
if (!foundSpineItem) return { x: 0, y: 0 };
|
|
6819
|
-
const { height, top } = spineLayout.
|
|
6817
|
+
const { height, top } = spineLayout.getSpineItemRelativeLayoutInfo(foundSpineItem);
|
|
6820
6818
|
const isPositionWithinSpineItem = spineLocator.isPositionWithinSpineItem(
|
|
6821
6819
|
navigation.position,
|
|
6822
6820
|
foundSpineItem
|
|
@@ -7383,13 +7381,13 @@
|
|
|
7383
7381
|
const shouldUpdateEndCfi = previousPagination.endSpineItemIndex !== endSpineItemIndex || endLastCfi === void 0 || isRootCfi(endLastCfi);
|
|
7384
7382
|
const beginCfi = shouldUpdateBeginCfi ? getRootCfi(beginSpineItem) : beginLastCfi;
|
|
7385
7383
|
const endCfi = shouldUpdateEndCfi ? getRootCfi(endSpineItem) : endLastCfi;
|
|
7386
|
-
const beginSpineItemDimensions = beginSpineItem.
|
|
7384
|
+
const beginSpineItemDimensions = beginSpineItem.layout.layoutInfo;
|
|
7387
7385
|
const beginNumberOfPagesInSpineItem = this.spineItemLocator.getSpineItemNumberOfPages({
|
|
7388
7386
|
itemHeight: beginSpineItemDimensions.height,
|
|
7389
7387
|
itemWidth: beginSpineItemDimensions.width,
|
|
7390
7388
|
isUsingVerticalWriting: !!beginSpineItem.isUsingVerticalWriting()
|
|
7391
7389
|
});
|
|
7392
|
-
const endSpineItemDimensions = endSpineItem.
|
|
7390
|
+
const endSpineItemDimensions = endSpineItem.layout.layoutInfo;
|
|
7393
7391
|
const endNumberOfPagesInSpineItem = this.spineItemLocator.getSpineItemNumberOfPages({
|
|
7394
7392
|
itemHeight: endSpineItemDimensions.height,
|
|
7395
7393
|
itemWidth: endSpineItemDimensions.width,
|
|
@@ -7578,7 +7576,7 @@
|
|
|
7578
7576
|
const { currentAbsolutePage } = items.reduce(
|
|
7579
7577
|
(acc, item) => {
|
|
7580
7578
|
if (acc.found) return acc;
|
|
7581
|
-
const itemLayout = spineLayout.
|
|
7579
|
+
const itemLayout = spineLayout.getSpineItemRelativeLayoutInfo(item);
|
|
7582
7580
|
const numberOfPages = getSpineItemNumberOfPages({
|
|
7583
7581
|
isUsingVerticalWriting: !!item.isUsingVerticalWriting(),
|
|
7584
7582
|
itemHeight: itemLayout.height,
|
|
@@ -7688,7 +7686,7 @@
|
|
|
7688
7686
|
const { found, currentAbsolutePage } = items.reduce(
|
|
7689
7687
|
(acc, item) => {
|
|
7690
7688
|
if (acc.found) return acc;
|
|
7691
|
-
const itemLayout = spineLayout.
|
|
7689
|
+
const itemLayout = spineLayout.getSpineItemRelativeLayoutInfo(item);
|
|
7692
7690
|
const numberOfPages = getSpineItemNumberOfPages({
|
|
7693
7691
|
isUsingVerticalWriting: !!item.isUsingVerticalWriting(),
|
|
7694
7692
|
itemHeight: itemLayout.height,
|
|
@@ -7729,7 +7727,7 @@
|
|
|
7729
7727
|
settings
|
|
7730
7728
|
}) => {
|
|
7731
7729
|
const spineItem = spineItemsManager.items.find((item) => {
|
|
7732
|
-
const { left, right, bottom, top } = spineLayout.
|
|
7730
|
+
const { left, right, bottom, top } = spineLayout.getSpineItemRelativeLayoutInfo(item);
|
|
7733
7731
|
const isWithinXAxis = position.x >= left && position.x < right;
|
|
7734
7732
|
if (settings.values.computedPageTurnDirection === `horizontal`) {
|
|
7735
7733
|
return isWithinXAxis;
|
|
@@ -7767,7 +7765,7 @@
|
|
|
7767
7765
|
}) || spineItemsManager.get(0);
|
|
7768
7766
|
const spineItemsVisible = spineItemsManager.items.reduce(
|
|
7769
7767
|
(acc, spineItem) => {
|
|
7770
|
-
const itemPosition = spineLayout.
|
|
7768
|
+
const itemPosition = spineLayout.getSpineItemRelativeLayoutInfo(spineItem);
|
|
7771
7769
|
const { visible } = getItemVisibilityForPosition({
|
|
7772
7770
|
itemPosition,
|
|
7773
7771
|
threshold,
|
|
@@ -7803,7 +7801,7 @@
|
|
|
7803
7801
|
`getSpineItemPositionFromSpinePosition`,
|
|
7804
7802
|
10,
|
|
7805
7803
|
(position, spineItem) => {
|
|
7806
|
-
const { left, top } = spineLayout.
|
|
7804
|
+
const { left, top } = spineLayout.getSpineItemRelativeLayoutInfo(spineItem);
|
|
7807
7805
|
return {
|
|
7808
7806
|
/**
|
|
7809
7807
|
* when using spread the item could be on the right and therefore will be negative
|
|
@@ -7821,7 +7819,7 @@
|
|
|
7821
7819
|
const getSpinePositionFromSpineItem = (spineItem) => {
|
|
7822
7820
|
return getSpinePositionFromSpineItemPosition({
|
|
7823
7821
|
spineItemPosition: { x: 0, y: 0 },
|
|
7824
|
-
itemLayout: spineLayout.
|
|
7822
|
+
itemLayout: spineLayout.getSpineItemRelativeLayoutInfo(spineItem)
|
|
7825
7823
|
});
|
|
7826
7824
|
};
|
|
7827
7825
|
const getSpineItemFromIframe = (iframe) => {
|
|
@@ -7851,7 +7849,7 @@
|
|
|
7851
7849
|
spineItem,
|
|
7852
7850
|
restrictToScreen
|
|
7853
7851
|
}) => {
|
|
7854
|
-
const { height, width } = spineItem.
|
|
7852
|
+
const { height, width } = spineItem.layout.layoutInfo;
|
|
7855
7853
|
const numberOfPages = spineItemLocator.getSpineItemNumberOfPages({
|
|
7856
7854
|
isUsingVerticalWriting: !!spineItem.isUsingVerticalWriting(),
|
|
7857
7855
|
itemHeight: height,
|
|
@@ -7861,11 +7859,11 @@
|
|
|
7861
7859
|
const spineItemPosition = spineItemLocator.getSpineItemPositionFromPageIndex({
|
|
7862
7860
|
pageIndex: index,
|
|
7863
7861
|
isUsingVerticalWriting: !!spineItem.isUsingVerticalWriting(),
|
|
7864
|
-
itemLayout: spineItem.
|
|
7862
|
+
itemLayout: spineItem.layout.layoutInfo
|
|
7865
7863
|
});
|
|
7866
7864
|
const spinePosition = getSpinePositionFromSpineItemPosition({
|
|
7867
7865
|
spineItemPosition,
|
|
7868
|
-
itemLayout: spineLayout.
|
|
7866
|
+
itemLayout: spineLayout.getSpineItemRelativeLayoutInfo(spineItem)
|
|
7869
7867
|
});
|
|
7870
7868
|
return {
|
|
7871
7869
|
index,
|
|
@@ -7905,11 +7903,11 @@
|
|
|
7905
7903
|
};
|
|
7906
7904
|
};
|
|
7907
7905
|
const isPositionWithinSpineItem = (position, spineItem) => {
|
|
7908
|
-
const { bottom, left, right, top } = spineLayout.
|
|
7906
|
+
const { bottom, left, right, top } = spineLayout.getSpineItemRelativeLayoutInfo(spineItem);
|
|
7909
7907
|
return position.x >= left && position.x <= right && position.y <= bottom && position.y >= top;
|
|
7910
7908
|
};
|
|
7911
7909
|
const getSafeSpineItemPositionFromUnsafeSpineItemPosition = (unsafePosition, spineItem) => {
|
|
7912
|
-
const { height, width } = spineLayout.
|
|
7910
|
+
const { height, width } = spineLayout.getSpineItemRelativeLayoutInfo(spineItem);
|
|
7913
7911
|
return {
|
|
7914
7912
|
x: Math.min(Math.max(0, unsafePosition.x), width),
|
|
7915
7913
|
y: Math.min(Math.max(0, unsafePosition.y), height)
|
|
@@ -7920,7 +7918,7 @@
|
|
|
7920
7918
|
spineItem,
|
|
7921
7919
|
spineItemPosition
|
|
7922
7920
|
}) => {
|
|
7923
|
-
const itemLayout = spineLayout.
|
|
7921
|
+
const itemLayout = spineLayout.getSpineItemRelativeLayoutInfo(spineItem);
|
|
7924
7922
|
return getSpinePositionFromSpineItemPosition({
|
|
7925
7923
|
itemLayout,
|
|
7926
7924
|
spineItemPosition
|
|
@@ -8115,7 +8113,7 @@
|
|
|
8115
8113
|
minimumWidth = context.getPageSize().width * 2;
|
|
8116
8114
|
}
|
|
8117
8115
|
}
|
|
8118
|
-
const itemLayout$ = item.layout({
|
|
8116
|
+
const itemLayout$ = item.layout.layout({
|
|
8119
8117
|
minimumWidth,
|
|
8120
8118
|
blankPagePosition,
|
|
8121
8119
|
spreadPosition: context.state.isUsingSpreadMode ? isScreenStartItem ? context.isRTL() ? `right` : `left` : context.isRTL() ? `left` : `right` : `none`
|
|
@@ -8126,29 +8124,52 @@
|
|
|
8126
8124
|
const currentValidEdgeYForVerticalPositioning = isScreenStartItem ? verticalOffset : verticalOffset - context.state.visibleAreaRect.height;
|
|
8127
8125
|
const currentValidEdgeXForVerticalPositioning = isScreenStartItem ? 0 : horizontalOffset;
|
|
8128
8126
|
if (context.isRTL()) {
|
|
8129
|
-
item.adjustPositionOfElement({
|
|
8127
|
+
item.layout.adjustPositionOfElement({
|
|
8130
8128
|
top: currentValidEdgeYForVerticalPositioning,
|
|
8131
8129
|
left: currentValidEdgeXForVerticalPositioning
|
|
8132
8130
|
});
|
|
8133
8131
|
} else {
|
|
8134
|
-
item.adjustPositionOfElement({
|
|
8132
|
+
item.layout.adjustPositionOfElement({
|
|
8135
8133
|
top: currentValidEdgeYForVerticalPositioning,
|
|
8136
8134
|
left: currentValidEdgeXForVerticalPositioning
|
|
8137
8135
|
});
|
|
8138
8136
|
}
|
|
8139
8137
|
const newEdgeX = width + currentValidEdgeXForVerticalPositioning;
|
|
8140
8138
|
const newEdgeY = height + currentValidEdgeYForVerticalPositioning;
|
|
8139
|
+
const layoutPosition2 = {
|
|
8140
|
+
left: currentValidEdgeXForVerticalPositioning,
|
|
8141
|
+
right: newEdgeX,
|
|
8142
|
+
top: currentValidEdgeYForVerticalPositioning,
|
|
8143
|
+
bottom: newEdgeY,
|
|
8144
|
+
height,
|
|
8145
|
+
width,
|
|
8146
|
+
x: currentValidEdgeXForVerticalPositioning,
|
|
8147
|
+
y: currentValidEdgeYForVerticalPositioning
|
|
8148
|
+
};
|
|
8141
8149
|
return {
|
|
8142
8150
|
horizontalOffset: newEdgeX,
|
|
8143
|
-
verticalOffset: newEdgeY
|
|
8151
|
+
verticalOffset: newEdgeY,
|
|
8152
|
+
layoutPosition: layoutPosition2
|
|
8144
8153
|
};
|
|
8145
8154
|
}
|
|
8146
|
-
item.adjustPositionOfElement(
|
|
8155
|
+
item.layout.adjustPositionOfElement(
|
|
8147
8156
|
context.isRTL() ? { right: horizontalOffset, top: 0 } : { left: horizontalOffset, top: 0 }
|
|
8148
8157
|
);
|
|
8158
|
+
const left = context.isRTL() ? context.state.visibleAreaRect.width - horizontalOffset - width : horizontalOffset;
|
|
8159
|
+
const layoutPosition = {
|
|
8160
|
+
right: context.isRTL() ? context.state.visibleAreaRect.width - horizontalOffset : horizontalOffset + width,
|
|
8161
|
+
left,
|
|
8162
|
+
x: left,
|
|
8163
|
+
top: verticalOffset,
|
|
8164
|
+
bottom: height,
|
|
8165
|
+
height,
|
|
8166
|
+
width,
|
|
8167
|
+
y: verticalOffset
|
|
8168
|
+
};
|
|
8149
8169
|
return {
|
|
8150
8170
|
horizontalOffset: horizontalOffset + width,
|
|
8151
|
-
verticalOffset: 0
|
|
8171
|
+
verticalOffset: 0,
|
|
8172
|
+
layoutPosition
|
|
8152
8173
|
};
|
|
8153
8174
|
})
|
|
8154
8175
|
);
|
|
@@ -8161,7 +8182,11 @@
|
|
|
8161
8182
|
this.context = context;
|
|
8162
8183
|
this.settings = settings;
|
|
8163
8184
|
this.layoutSubject = new rxjs.Subject();
|
|
8185
|
+
this.spineItemsRelativeLayouts = [];
|
|
8164
8186
|
spineItemsManager.items$.pipe(
|
|
8187
|
+
rxjs.tap(() => {
|
|
8188
|
+
this.spineItemsRelativeLayouts = [];
|
|
8189
|
+
}),
|
|
8165
8190
|
rxjs.switchMap((items) => {
|
|
8166
8191
|
const needsLayouts$ = items.map(
|
|
8167
8192
|
(spineItem) => spineItem.needsLayout$.pipe(
|
|
@@ -8202,28 +8227,41 @@
|
|
|
8202
8227
|
layoutInProgress.next(true);
|
|
8203
8228
|
const manifest = this.context.manifest;
|
|
8204
8229
|
const isGloballyPrePaginated = isFullyPrePaginated(manifest) ?? false;
|
|
8205
|
-
|
|
8230
|
+
const items$ = rxjs.from(this.spineItemsManager.items);
|
|
8231
|
+
return items$.pipe(
|
|
8206
8232
|
rxjs.reduce(
|
|
8207
|
-
(acc$, item,
|
|
8233
|
+
(acc$, item, itemIndex) => acc$.pipe(
|
|
8208
8234
|
rxjs.concatMap(
|
|
8209
|
-
({ horizontalOffset, verticalOffset }) => layoutItem({
|
|
8235
|
+
({ horizontalOffset, verticalOffset, pages }) => layoutItem({
|
|
8210
8236
|
context: this.context,
|
|
8211
8237
|
horizontalOffset,
|
|
8212
|
-
index,
|
|
8238
|
+
index: itemIndex,
|
|
8213
8239
|
isGloballyPrePaginated,
|
|
8214
8240
|
item,
|
|
8215
8241
|
settings: this.settings,
|
|
8216
8242
|
spineItemsManager: this.spineItemsManager,
|
|
8217
8243
|
verticalOffset
|
|
8218
|
-
})
|
|
8244
|
+
}).pipe(
|
|
8245
|
+
rxjs.map(
|
|
8246
|
+
({
|
|
8247
|
+
horizontalOffset: newHorizontalOffset,
|
|
8248
|
+
verticalOffset: newVerticalOffset,
|
|
8249
|
+
layoutPosition
|
|
8250
|
+
}) => {
|
|
8251
|
+
this.spineItemsRelativeLayouts[itemIndex] = layoutPosition;
|
|
8252
|
+
return {
|
|
8253
|
+
horizontalOffset: newHorizontalOffset,
|
|
8254
|
+
verticalOffset: newVerticalOffset,
|
|
8255
|
+
pages: [...pages, layoutPosition]
|
|
8256
|
+
};
|
|
8257
|
+
}
|
|
8258
|
+
)
|
|
8259
|
+
)
|
|
8219
8260
|
)
|
|
8220
8261
|
),
|
|
8221
|
-
rxjs.of({ horizontalOffset: 0, verticalOffset: 0 })
|
|
8262
|
+
rxjs.of({ horizontalOffset: 0, verticalOffset: 0, pages: [] })
|
|
8222
8263
|
),
|
|
8223
8264
|
rxjs.concatMap((layout$) => layout$),
|
|
8224
|
-
rxjs.tap(() => {
|
|
8225
|
-
Report.log(NAMESPACE, `layout`);
|
|
8226
|
-
}),
|
|
8227
8265
|
rxjs.finalize(() => {
|
|
8228
8266
|
layoutInProgress.next(false);
|
|
8229
8267
|
})
|
|
@@ -8232,7 +8270,7 @@
|
|
|
8232
8270
|
rxjs.map(() => {
|
|
8233
8271
|
const items = spineItemsManager.items;
|
|
8234
8272
|
const spineItemsPagesAbsolutePositions = items.map((item) => {
|
|
8235
|
-
const itemLayout = this.
|
|
8273
|
+
const itemLayout = this.getSpineItemRelativeLayoutInfo(item);
|
|
8236
8274
|
const numberOfPages = getSpineItemNumberOfPages({
|
|
8237
8275
|
isUsingVerticalWriting: !!item.isUsingVerticalWriting(),
|
|
8238
8276
|
itemHeight: itemLayout.height,
|
|
@@ -8270,16 +8308,16 @@
|
|
|
8270
8308
|
[]
|
|
8271
8309
|
);
|
|
8272
8310
|
return {
|
|
8273
|
-
spineItemsAbsolutePositions:
|
|
8274
|
-
(item) => this.getAbsolutePositionOf(item)
|
|
8275
|
-
),
|
|
8276
|
-
spineItemsPagesAbsolutePositions,
|
|
8311
|
+
spineItemsAbsolutePositions: [...this.spineItemsRelativeLayouts],
|
|
8277
8312
|
pages
|
|
8278
8313
|
};
|
|
8279
8314
|
}),
|
|
8280
8315
|
rxjs.share()
|
|
8281
8316
|
);
|
|
8282
8317
|
this.info$ = this.layout$.pipe(
|
|
8318
|
+
rxjs.tap((layout) => {
|
|
8319
|
+
Report.log(NAMESPACE, `layout:info`, layout);
|
|
8320
|
+
}),
|
|
8283
8321
|
rxjs.shareReplay({ refCount: true, bufferSize: 1 })
|
|
8284
8322
|
);
|
|
8285
8323
|
rxjs.merge(this.layout$, this.info$).pipe(rxjs.takeUntil(this.destroy$)).subscribe();
|
|
@@ -8287,9 +8325,9 @@
|
|
|
8287
8325
|
layout() {
|
|
8288
8326
|
this.layoutSubject.next(void 0);
|
|
8289
8327
|
}
|
|
8290
|
-
|
|
8291
|
-
|
|
8292
|
-
return
|
|
8328
|
+
getSpineItemRelativeLayoutInfo(spineItemOrIndex) {
|
|
8329
|
+
const itemIndex = this.spineItemsManager.getSpineItemIndex(spineItemOrIndex) ?? 0;
|
|
8330
|
+
return this.spineItemsRelativeLayouts[itemIndex] || {
|
|
8293
8331
|
left: 0,
|
|
8294
8332
|
right: 0,
|
|
8295
8333
|
top: 0,
|
|
@@ -8423,34 +8461,14 @@
|
|
|
8423
8461
|
const adjustedValue = multiplier * pageSize;
|
|
8424
8462
|
return Math.max(adjustedValue, pageSize);
|
|
8425
8463
|
}
|
|
8426
|
-
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
|
|
8430
|
-
|
|
8431
|
-
*
|
|
8432
|
-
* This method is stable and does not consider scalings or transforms on the parents.
|
|
8433
|
-
*
|
|
8434
|
-
* It does assume and requires that:
|
|
8435
|
-
* - the navigator element and the spine element are direct parents.
|
|
8436
|
-
* - the spine items are correctly positioned in the DOM and with correct styles values.
|
|
8437
|
-
*/
|
|
8438
|
-
get layoutPosition() {
|
|
8439
|
-
const left = Math.round(this.containerElement.offsetLeft * 10) / 10;
|
|
8440
|
-
const top = Math.round(this.containerElement.offsetTop * 10) / 10;
|
|
8441
|
-
const width = Math.round(this.containerElement.offsetWidth * 10) / 10;
|
|
8442
|
-
const height = Math.round(this.containerElement.offsetHeight * 10) / 10;
|
|
8443
|
-
const normalizedValues = {
|
|
8444
|
-
left,
|
|
8445
|
-
top,
|
|
8446
|
-
right: left + width,
|
|
8447
|
-
bottom: top + height,
|
|
8448
|
-
x: left,
|
|
8449
|
-
y: top,
|
|
8464
|
+
get layoutInfo() {
|
|
8465
|
+
const style = this.containerElement.style;
|
|
8466
|
+
const width = style.width ? parseFloat(style.width) : 0;
|
|
8467
|
+
const height = style.height ? parseFloat(style.height) : 0;
|
|
8468
|
+
return {
|
|
8450
8469
|
width,
|
|
8451
8470
|
height
|
|
8452
8471
|
};
|
|
8453
|
-
return normalizedValues;
|
|
8454
8472
|
}
|
|
8455
8473
|
}
|
|
8456
8474
|
class DefaultRenderer extends DocumentRenderer {
|
|
@@ -8525,21 +8543,23 @@
|
|
|
8525
8543
|
resourcesHandler: this.resourcesHandler
|
|
8526
8544
|
};
|
|
8527
8545
|
this.renderer = rendererFactory ? rendererFactory(rendererParams) : new DefaultRenderer(rendererParams);
|
|
8528
|
-
this.
|
|
8546
|
+
this.layout = new SpineItemLayout(
|
|
8529
8547
|
item,
|
|
8530
8548
|
this.containerElement,
|
|
8531
8549
|
context,
|
|
8532
8550
|
hookManager,
|
|
8533
8551
|
this.renderer
|
|
8534
8552
|
);
|
|
8535
|
-
this.isReady$ = this.
|
|
8553
|
+
this.isReady$ = this.layout.layoutProcess$.pipe(
|
|
8536
8554
|
operators.withLatestFrom(this.renderer.isLoaded$),
|
|
8537
8555
|
operators.map(([event, loaded]) => !!(event.type === `end` && loaded)),
|
|
8538
8556
|
operators.startWith(false),
|
|
8539
8557
|
operators.distinctUntilChanged(),
|
|
8558
|
+
operators.tap((isReady) => {
|
|
8559
|
+
this.containerElement.dataset["isReady"] = isReady.toString();
|
|
8560
|
+
}),
|
|
8540
8561
|
operators.shareReplay({ refCount: true, bufferSize: 1 })
|
|
8541
8562
|
);
|
|
8542
|
-
this.layout$ = this.spineItemLayout.layout$;
|
|
8543
8563
|
this.needsLayout$ = rxjs.merge(this.unloaded$, this.loaded$);
|
|
8544
8564
|
rxjs.merge(
|
|
8545
8565
|
/**
|
|
@@ -8549,10 +8569,8 @@
|
|
|
8549
8569
|
* to layout changes may rely on the isReady value.
|
|
8550
8570
|
*/
|
|
8551
8571
|
this.isReady$,
|
|
8552
|
-
this.
|
|
8572
|
+
this.layout.layout$
|
|
8553
8573
|
).pipe(operators.takeUntil(this.destroy$)).subscribe();
|
|
8554
|
-
this.layout = this.spineItemLayout.layout;
|
|
8555
|
-
this.adjustPositionOfElement = this.spineItemLayout.adjustPositionOfElement;
|
|
8556
8574
|
}
|
|
8557
8575
|
get element() {
|
|
8558
8576
|
return this.containerElement;
|
|
@@ -8568,9 +8586,6 @@
|
|
|
8568
8586
|
get readingDirection() {
|
|
8569
8587
|
return this.renderer.readingDirection;
|
|
8570
8588
|
}
|
|
8571
|
-
get layoutPosition() {
|
|
8572
|
-
return this.spineItemLayout.layoutPosition;
|
|
8573
|
-
}
|
|
8574
8589
|
get loaded$() {
|
|
8575
8590
|
return this.renderer.state$.pipe(
|
|
8576
8591
|
operators.distinctUntilChanged(),
|
|
@@ -8601,6 +8616,7 @@
|
|
|
8601
8616
|
position: absolute;
|
|
8602
8617
|
overflow: hidden;
|
|
8603
8618
|
`;
|
|
8619
|
+
element.dataset["isReady"] = `false`;
|
|
8604
8620
|
hookManager.execute("item.onBeforeContainerCreated", void 0, { element });
|
|
8605
8621
|
return element;
|
|
8606
8622
|
};
|