@prose-reader/core 1.193.0 → 1.194.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/createReaderWithEnhancer.d.ts +1 -1
- package/dist/index.js +151 -171
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +151 -171
- package/dist/index.umd.cjs.map +1 -1
- package/dist/navigation/consolidation/withSpineItemPosition.d.ts +2 -2
- package/dist/navigation/resolvers/getNavigationForSpineItemPage.d.ts +1 -1
- package/dist/navigation/resolvers/getNavigationForUrl.d.ts +2 -2
- package/dist/navigation/tests/utils.d.ts +9 -4
- package/dist/pagination/PaginationController.d.ts +3 -3
- package/dist/reader.d.ts +1 -1
- package/dist/spine/SpineLayout.d.ts +4 -7
- package/dist/spine/layout/layoutItem.d.ts +1 -3
- package/dist/spine/locator/SpineLocator.d.ts +5 -5
- package/dist/spineItem/SpineItem.d.ts +12 -12
- package/dist/spineItem/SpineItemLayout.d.ts +10 -0
- package/dist/spineItem/locationResolver.d.ts +1 -1
- package/dist/spineItem/navigationResolver.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.umd.cjs
CHANGED
|
@@ -3301,7 +3301,7 @@
|
|
|
3301
3301
|
};
|
|
3302
3302
|
const getScrollPercentageWithinItem = (reader, currentPosition, currentItem) => {
|
|
3303
3303
|
const context = reader.context;
|
|
3304
|
-
const { height, width } = currentItem.
|
|
3304
|
+
const { height, width } = currentItem.layoutPosition;
|
|
3305
3305
|
const { top, left } = reader.spine.spineLayout.getAbsolutePositionOf(currentItem);
|
|
3306
3306
|
if (reader.settings.values.computedPageTurnDirection === `vertical`) {
|
|
3307
3307
|
return Math.max(
|
|
@@ -3365,7 +3365,7 @@
|
|
|
3365
3365
|
);
|
|
3366
3366
|
};
|
|
3367
3367
|
const getNumberOfPagesForAllSpineItems = (reader) => reader.spineItemsManager.items.map((item) => {
|
|
3368
|
-
const { height, width } = item.
|
|
3368
|
+
const { height, width } = item.layoutPosition;
|
|
3369
3369
|
return reader.spine.spineItemLocator.getSpineItemNumberOfPages({
|
|
3370
3370
|
isUsingVerticalWriting: !!item.isUsingVerticalWriting(),
|
|
3371
3371
|
itemHeight: height,
|
|
@@ -5565,7 +5565,7 @@
|
|
|
5565
5565
|
const range = node ? getRangeFromNode(node, offset) : void 0;
|
|
5566
5566
|
offsetOfNodeInSpineItem = (range == null ? void 0 : range.getBoundingClientRect().x) || offsetOfNodeInSpineItem;
|
|
5567
5567
|
}
|
|
5568
|
-
const spineItemWidth = ((_a = spineItem.
|
|
5568
|
+
const spineItemWidth = ((_a = spineItem.layoutPosition) == null ? void 0 : _a.width) || 0;
|
|
5569
5569
|
const pageWidth = context.getPageSize().width;
|
|
5570
5570
|
if (offsetOfNodeInSpineItem !== void 0) {
|
|
5571
5571
|
const val = getClosestValidOffsetFromApproximateOffsetInPages(
|
|
@@ -5585,7 +5585,7 @@
|
|
|
5585
5585
|
frame.contentWindow.document.body !== null) {
|
|
5586
5586
|
const { x: left, y: top } = getSpineItemPositionFromPageIndex({
|
|
5587
5587
|
pageIndex,
|
|
5588
|
-
itemLayout: spineItem.
|
|
5588
|
+
itemLayout: spineItem.layoutPosition,
|
|
5589
5589
|
context,
|
|
5590
5590
|
isUsingVerticalWriting: !!spineItem.isUsingVerticalWriting()
|
|
5591
5591
|
});
|
|
@@ -5604,7 +5604,7 @@
|
|
|
5604
5604
|
return void 0;
|
|
5605
5605
|
};
|
|
5606
5606
|
const getSpineItemClosestPositionFromUnsafePosition = (unsafePosition, spineItem) => {
|
|
5607
|
-
const { width, height } = spineItem.
|
|
5607
|
+
const { width, height } = spineItem.layoutPosition;
|
|
5608
5608
|
const adjustedPosition = {
|
|
5609
5609
|
x: getClosestValidOffsetFromApproximateOffsetInPages(
|
|
5610
5610
|
unsafePosition.x,
|
|
@@ -5621,7 +5621,7 @@
|
|
|
5621
5621
|
};
|
|
5622
5622
|
const getSpineItemPageIndexFromNode = (node, offset, spineItem) => {
|
|
5623
5623
|
const position = getSpineItemPositionFromNode(node, offset, spineItem);
|
|
5624
|
-
const { height, width } = spineItem.
|
|
5624
|
+
const { height, width } = spineItem.layoutPosition;
|
|
5625
5625
|
return position ? getSpineItemPageIndexFromPosition({
|
|
5626
5626
|
isUsingVerticalWriting: !!spineItem.isUsingVerticalWriting(),
|
|
5627
5627
|
position,
|
|
@@ -5659,7 +5659,7 @@
|
|
|
5659
5659
|
context,
|
|
5660
5660
|
isUsingVerticalWriting: !!item.isUsingVerticalWriting(),
|
|
5661
5661
|
settings,
|
|
5662
|
-
itemLayout: item.
|
|
5662
|
+
itemLayout: item.layoutPosition
|
|
5663
5663
|
});
|
|
5664
5664
|
},
|
|
5665
5665
|
getSpineItemNumberOfPages: (params) => getSpineItemNumberOfPages({
|
|
@@ -5675,7 +5675,7 @@
|
|
|
5675
5675
|
}) => {
|
|
5676
5676
|
const spineItemLocator = createSpineItemLocator({ context, settings });
|
|
5677
5677
|
const getNavigationForLastPage = (spineItem) => {
|
|
5678
|
-
const { height, width } = spineItem.
|
|
5678
|
+
const { height, width } = spineItem.layoutPosition;
|
|
5679
5679
|
const numberOfPages = spineItemLocator.getSpineItemNumberOfPages({
|
|
5680
5680
|
isUsingVerticalWriting: !!spineItem.isUsingVerticalWriting(),
|
|
5681
5681
|
itemHeight: height,
|
|
@@ -5684,7 +5684,7 @@
|
|
|
5684
5684
|
return spineItemLocator.getSpineItemPositionFromPageIndex({
|
|
5685
5685
|
pageIndex: numberOfPages - 1,
|
|
5686
5686
|
isUsingVerticalWriting: !!spineItem.isUsingVerticalWriting(),
|
|
5687
|
-
itemLayout: spineItem.
|
|
5687
|
+
itemLayout: spineItem.layoutPosition
|
|
5688
5688
|
});
|
|
5689
5689
|
};
|
|
5690
5690
|
const getNavigationFromNode = (spineItem, node, offset) => {
|
|
@@ -5751,7 +5751,7 @@
|
|
|
5751
5751
|
context
|
|
5752
5752
|
}) => {
|
|
5753
5753
|
var _a;
|
|
5754
|
-
const itemWidth = ((_a = spineItem.
|
|
5754
|
+
const itemWidth = ((_a = spineItem.layoutPosition) == null ? void 0 : _a.width) || 0;
|
|
5755
5755
|
const pageWidth = context.getPageSize().width;
|
|
5756
5756
|
const anchorElementBoundingRect = spineItem.getBoundingRectOfElementFromSelector(anchor);
|
|
5757
5757
|
const offsetOfAnchor = (anchorElementBoundingRect == null ? void 0 : anchorElementBoundingRect.x) || 0;
|
|
@@ -5910,7 +5910,7 @@
|
|
|
5910
5910
|
const spineItemNavigation = spineLocator.spineItemLocator.getSpineItemPositionFromPageIndex({
|
|
5911
5911
|
pageIndex,
|
|
5912
5912
|
isUsingVerticalWriting: !!spineItem.isUsingVerticalWriting(),
|
|
5913
|
-
itemLayout: spineItem.
|
|
5913
|
+
itemLayout: spineItem.layoutPosition
|
|
5914
5914
|
});
|
|
5915
5915
|
const readingOffset = spineLocator.getSpinePositionFromSpineItemPosition({
|
|
5916
5916
|
spineItemPosition: spineItemNavigation,
|
|
@@ -6677,7 +6677,7 @@
|
|
|
6677
6677
|
const positionInSpineItem = spineLocator.spineItemLocator.getSpineItemPositionFromPageIndex({
|
|
6678
6678
|
pageIndex: beginPageIndexForDirection,
|
|
6679
6679
|
isUsingVerticalWriting: !!spineItem.isUsingVerticalWriting(),
|
|
6680
|
-
itemLayout: spineItem.
|
|
6680
|
+
itemLayout: spineItem.layoutPosition
|
|
6681
6681
|
});
|
|
6682
6682
|
return positionInSpineItem;
|
|
6683
6683
|
}
|
|
@@ -7376,13 +7376,13 @@
|
|
|
7376
7376
|
const shouldUpdateEndCfi = previousPagination.endSpineItemIndex !== endSpineItemIndex || endLastCfi === void 0 || isRootCfi(endLastCfi);
|
|
7377
7377
|
const beginCfi = shouldUpdateBeginCfi ? getRootCfi(beginSpineItem) : beginLastCfi;
|
|
7378
7378
|
const endCfi = shouldUpdateEndCfi ? getRootCfi(endSpineItem) : endLastCfi;
|
|
7379
|
-
const beginSpineItemDimensions = beginSpineItem.
|
|
7379
|
+
const beginSpineItemDimensions = beginSpineItem.layoutPosition;
|
|
7380
7380
|
const beginNumberOfPagesInSpineItem = this.spineItemLocator.getSpineItemNumberOfPages({
|
|
7381
7381
|
itemHeight: beginSpineItemDimensions.height,
|
|
7382
7382
|
itemWidth: beginSpineItemDimensions.width,
|
|
7383
7383
|
isUsingVerticalWriting: !!beginSpineItem.isUsingVerticalWriting()
|
|
7384
7384
|
});
|
|
7385
|
-
const endSpineItemDimensions = endSpineItem.
|
|
7385
|
+
const endSpineItemDimensions = endSpineItem.layoutPosition;
|
|
7386
7386
|
const endNumberOfPagesInSpineItem = this.spineItemLocator.getSpineItemNumberOfPages({
|
|
7387
7387
|
itemHeight: endSpineItemDimensions.height,
|
|
7388
7388
|
itemWidth: endSpineItemDimensions.width,
|
|
@@ -7557,24 +7557,44 @@
|
|
|
7557
7557
|
};
|
|
7558
7558
|
}
|
|
7559
7559
|
}
|
|
7560
|
-
const
|
|
7561
|
-
|
|
7562
|
-
|
|
7560
|
+
const getAbsolutePageIndexFromPageIndex = ({
|
|
7561
|
+
pageIndex,
|
|
7562
|
+
spineItemOrId,
|
|
7563
7563
|
spineLayout,
|
|
7564
|
+
spineItemsManager,
|
|
7565
|
+
context,
|
|
7564
7566
|
settings
|
|
7565
7567
|
}) => {
|
|
7566
|
-
const
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
|
|
7568
|
+
const items = spineItemsManager.items;
|
|
7569
|
+
const spineItem = spineItemsManager.get(spineItemOrId);
|
|
7570
|
+
if (!spineItem) return void 0;
|
|
7571
|
+
const { currentAbsolutePage } = items.reduce(
|
|
7572
|
+
(acc, item) => {
|
|
7573
|
+
if (acc.found) return acc;
|
|
7574
|
+
const itemLayout = spineLayout.getAbsolutePositionOf(item);
|
|
7575
|
+
const numberOfPages = getSpineItemNumberOfPages({
|
|
7576
|
+
isUsingVerticalWriting: !!item.isUsingVerticalWriting(),
|
|
7577
|
+
itemHeight: itemLayout.height,
|
|
7578
|
+
itemWidth: itemLayout.width,
|
|
7579
|
+
context,
|
|
7580
|
+
settings
|
|
7581
|
+
});
|
|
7582
|
+
if (spineItem === item) {
|
|
7583
|
+
if (pageIndex <= numberOfPages - 1) {
|
|
7584
|
+
return {
|
|
7585
|
+
currentAbsolutePage: acc.currentAbsolutePage + pageIndex,
|
|
7586
|
+
found: true
|
|
7587
|
+
};
|
|
7588
|
+
}
|
|
7589
|
+
}
|
|
7590
|
+
return {
|
|
7591
|
+
...acc,
|
|
7592
|
+
currentAbsolutePage: acc.currentAbsolutePage + numberOfPages
|
|
7593
|
+
};
|
|
7594
|
+
},
|
|
7595
|
+
{ currentAbsolutePage: 0, found: false }
|
|
7596
|
+
);
|
|
7597
|
+
return currentAbsolutePage;
|
|
7578
7598
|
};
|
|
7579
7599
|
const isItemVisibleByThresholdForPosition = ({
|
|
7580
7600
|
itemHeight,
|
|
@@ -7650,57 +7670,6 @@
|
|
|
7650
7670
|
visible: isItemVisibleEnough || isItemVisibleEnoughOnScreen
|
|
7651
7671
|
};
|
|
7652
7672
|
};
|
|
7653
|
-
const getVisibleSpineItemsFromPosition = ({
|
|
7654
|
-
position,
|
|
7655
|
-
threshold,
|
|
7656
|
-
restrictToScreen,
|
|
7657
|
-
spineItemsManager,
|
|
7658
|
-
context,
|
|
7659
|
-
settings,
|
|
7660
|
-
spineLayout
|
|
7661
|
-
}) => {
|
|
7662
|
-
const fallbackSpineItem = getSpineItemFromPosition({
|
|
7663
|
-
position,
|
|
7664
|
-
settings,
|
|
7665
|
-
spineItemsManager,
|
|
7666
|
-
spineLayout
|
|
7667
|
-
}) || spineItemsManager.get(0);
|
|
7668
|
-
const spineItemsVisible = spineItemsManager.items.reduce(
|
|
7669
|
-
(acc, spineItem) => {
|
|
7670
|
-
const itemPosition = spineLayout.getAbsolutePositionOf(spineItem);
|
|
7671
|
-
const { visible } = getItemVisibilityForPosition({
|
|
7672
|
-
itemPosition,
|
|
7673
|
-
threshold,
|
|
7674
|
-
viewportPosition: position,
|
|
7675
|
-
restrictToScreen,
|
|
7676
|
-
context
|
|
7677
|
-
});
|
|
7678
|
-
if (visible) {
|
|
7679
|
-
return [...acc, spineItem];
|
|
7680
|
-
}
|
|
7681
|
-
return acc;
|
|
7682
|
-
},
|
|
7683
|
-
[]
|
|
7684
|
-
);
|
|
7685
|
-
const beginItem = spineItemsVisible[0] ?? fallbackSpineItem;
|
|
7686
|
-
const endItem = spineItemsVisible[spineItemsVisible.length - 1] ?? beginItem;
|
|
7687
|
-
if (!beginItem || !endItem) return void 0;
|
|
7688
|
-
const beginItemIndex = spineItemsManager.getSpineItemIndex(beginItem);
|
|
7689
|
-
const endItemIndex = spineItemsManager.getSpineItemIndex(endItem);
|
|
7690
|
-
return {
|
|
7691
|
-
beginIndex: beginItemIndex ?? 0,
|
|
7692
|
-
endIndex: endItemIndex ?? 0
|
|
7693
|
-
};
|
|
7694
|
-
};
|
|
7695
|
-
const getSpinePositionFromSpineItemPosition = ({
|
|
7696
|
-
spineItemPosition,
|
|
7697
|
-
itemLayout: { left, top }
|
|
7698
|
-
}) => {
|
|
7699
|
-
return {
|
|
7700
|
-
x: left + spineItemPosition.x,
|
|
7701
|
-
y: top + spineItemPosition.y
|
|
7702
|
-
};
|
|
7703
|
-
};
|
|
7704
7673
|
const getSpineInfoFromAbsolutePageIndex = ({
|
|
7705
7674
|
absolutePageIndex,
|
|
7706
7675
|
spineLayout,
|
|
@@ -7746,44 +7715,75 @@
|
|
|
7746
7715
|
}
|
|
7747
7716
|
return void 0;
|
|
7748
7717
|
};
|
|
7749
|
-
const
|
|
7750
|
-
|
|
7751
|
-
|
|
7718
|
+
const getSpineItemFromPosition = ({
|
|
7719
|
+
position,
|
|
7720
|
+
spineItemsManager,
|
|
7752
7721
|
spineLayout,
|
|
7722
|
+
settings
|
|
7723
|
+
}) => {
|
|
7724
|
+
const spineItem = spineItemsManager.items.find((item) => {
|
|
7725
|
+
const { left, right, bottom, top } = spineLayout.getAbsolutePositionOf(item);
|
|
7726
|
+
const isWithinXAxis = position.x >= left && position.x < right;
|
|
7727
|
+
if (settings.values.computedPageTurnDirection === `horizontal`) {
|
|
7728
|
+
return isWithinXAxis;
|
|
7729
|
+
}
|
|
7730
|
+
return isWithinXAxis && position.y >= top && position.y < bottom;
|
|
7731
|
+
});
|
|
7732
|
+
if (position.x === 0 && !spineItem) {
|
|
7733
|
+
return spineItemsManager.items[0];
|
|
7734
|
+
}
|
|
7735
|
+
return spineItem;
|
|
7736
|
+
};
|
|
7737
|
+
const getSpinePositionFromSpineItemPosition = ({
|
|
7738
|
+
spineItemPosition,
|
|
7739
|
+
itemLayout: { left, top }
|
|
7740
|
+
}) => {
|
|
7741
|
+
return {
|
|
7742
|
+
x: left + spineItemPosition.x,
|
|
7743
|
+
y: top + spineItemPosition.y
|
|
7744
|
+
};
|
|
7745
|
+
};
|
|
7746
|
+
const getVisibleSpineItemsFromPosition = ({
|
|
7747
|
+
position,
|
|
7748
|
+
threshold,
|
|
7749
|
+
restrictToScreen,
|
|
7753
7750
|
spineItemsManager,
|
|
7754
7751
|
context,
|
|
7755
|
-
settings
|
|
7752
|
+
settings,
|
|
7753
|
+
spineLayout
|
|
7756
7754
|
}) => {
|
|
7757
|
-
const
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7755
|
+
const fallbackSpineItem = getSpineItemFromPosition({
|
|
7756
|
+
position,
|
|
7757
|
+
settings,
|
|
7758
|
+
spineItemsManager,
|
|
7759
|
+
spineLayout
|
|
7760
|
+
}) || spineItemsManager.get(0);
|
|
7761
|
+
const spineItemsVisible = spineItemsManager.items.reduce(
|
|
7762
|
+
(acc, spineItem) => {
|
|
7763
|
+
const itemPosition = spineLayout.getAbsolutePositionOf(spineItem);
|
|
7764
|
+
const { visible } = getItemVisibilityForPosition({
|
|
7765
|
+
itemPosition,
|
|
7766
|
+
threshold,
|
|
7767
|
+
viewportPosition: position,
|
|
7768
|
+
restrictToScreen,
|
|
7769
|
+
context
|
|
7770
7770
|
});
|
|
7771
|
-
if (
|
|
7772
|
-
|
|
7773
|
-
return {
|
|
7774
|
-
currentAbsolutePage: acc.currentAbsolutePage + pageIndex,
|
|
7775
|
-
found: true
|
|
7776
|
-
};
|
|
7777
|
-
}
|
|
7771
|
+
if (visible) {
|
|
7772
|
+
return [...acc, spineItem];
|
|
7778
7773
|
}
|
|
7779
|
-
return
|
|
7780
|
-
...acc,
|
|
7781
|
-
currentAbsolutePage: acc.currentAbsolutePage + numberOfPages
|
|
7782
|
-
};
|
|
7774
|
+
return acc;
|
|
7783
7775
|
},
|
|
7784
|
-
|
|
7776
|
+
[]
|
|
7785
7777
|
);
|
|
7786
|
-
|
|
7778
|
+
const beginItem = spineItemsVisible[0] ?? fallbackSpineItem;
|
|
7779
|
+
const endItem = spineItemsVisible[spineItemsVisible.length - 1] ?? beginItem;
|
|
7780
|
+
if (!beginItem || !endItem) return void 0;
|
|
7781
|
+
const beginItemIndex = spineItemsManager.getSpineItemIndex(beginItem);
|
|
7782
|
+
const endItemIndex = spineItemsManager.getSpineItemIndex(endItem);
|
|
7783
|
+
return {
|
|
7784
|
+
beginIndex: beginItemIndex ?? 0,
|
|
7785
|
+
endIndex: endItemIndex ?? 0
|
|
7786
|
+
};
|
|
7787
7787
|
};
|
|
7788
7788
|
const createSpineLocator = ({
|
|
7789
7789
|
spineItemsManager,
|
|
@@ -7844,7 +7844,7 @@
|
|
|
7844
7844
|
spineItem,
|
|
7845
7845
|
restrictToScreen
|
|
7846
7846
|
}) => {
|
|
7847
|
-
const { height, width } = spineItem.
|
|
7847
|
+
const { height, width } = spineItem.layoutPosition;
|
|
7848
7848
|
const numberOfPages = spineItemLocator.getSpineItemNumberOfPages({
|
|
7849
7849
|
isUsingVerticalWriting: !!spineItem.isUsingVerticalWriting(),
|
|
7850
7850
|
itemHeight: height,
|
|
@@ -7854,7 +7854,7 @@
|
|
|
7854
7854
|
const spineItemPosition = spineItemLocator.getSpineItemPositionFromPageIndex({
|
|
7855
7855
|
pageIndex: index,
|
|
7856
7856
|
isUsingVerticalWriting: !!spineItem.isUsingVerticalWriting(),
|
|
7857
|
-
itemLayout: spineItem.
|
|
7857
|
+
itemLayout: spineItem.layoutPosition
|
|
7858
7858
|
});
|
|
7859
7859
|
const spinePosition = getSpinePositionFromSpineItemPosition({
|
|
7860
7860
|
spineItemPosition,
|
|
@@ -8079,8 +8079,7 @@
|
|
|
8079
8079
|
isGloballyPrePaginated,
|
|
8080
8080
|
settings,
|
|
8081
8081
|
index,
|
|
8082
|
-
item
|
|
8083
|
-
newItemLayoutInformation
|
|
8082
|
+
item
|
|
8084
8083
|
}) => {
|
|
8085
8084
|
let minimumWidth = context.getPageSize().width;
|
|
8086
8085
|
let blankPagePosition = `none`;
|
|
@@ -8132,16 +8131,6 @@
|
|
|
8132
8131
|
}
|
|
8133
8132
|
const newEdgeX = width + currentValidEdgeXForVerticalPositioning;
|
|
8134
8133
|
const newEdgeY = height + currentValidEdgeYForVerticalPositioning;
|
|
8135
|
-
newItemLayoutInformation.push({
|
|
8136
|
-
left: currentValidEdgeXForVerticalPositioning,
|
|
8137
|
-
right: newEdgeX,
|
|
8138
|
-
top: currentValidEdgeYForVerticalPositioning,
|
|
8139
|
-
bottom: newEdgeY,
|
|
8140
|
-
height,
|
|
8141
|
-
width,
|
|
8142
|
-
x: currentValidEdgeXForVerticalPositioning,
|
|
8143
|
-
y: currentValidEdgeYForVerticalPositioning
|
|
8144
|
-
});
|
|
8145
8134
|
return {
|
|
8146
8135
|
horizontalOffset: newEdgeX,
|
|
8147
8136
|
verticalOffset: newEdgeY
|
|
@@ -8150,17 +8139,6 @@
|
|
|
8150
8139
|
item.adjustPositionOfElement(
|
|
8151
8140
|
context.isRTL() ? { right: horizontalOffset, top: 0 } : { left: horizontalOffset, top: 0 }
|
|
8152
8141
|
);
|
|
8153
|
-
const left = context.isRTL() ? context.state.visibleAreaRect.width - horizontalOffset - width : horizontalOffset;
|
|
8154
|
-
newItemLayoutInformation.push({
|
|
8155
|
-
right: context.isRTL() ? context.state.visibleAreaRect.width - horizontalOffset : horizontalOffset + width,
|
|
8156
|
-
left,
|
|
8157
|
-
x: left,
|
|
8158
|
-
top: verticalOffset,
|
|
8159
|
-
bottom: height,
|
|
8160
|
-
height,
|
|
8161
|
-
width,
|
|
8162
|
-
y: verticalOffset
|
|
8163
|
-
});
|
|
8164
8142
|
return {
|
|
8165
8143
|
horizontalOffset: horizontalOffset + width,
|
|
8166
8144
|
verticalOffset: 0
|
|
@@ -8175,7 +8153,6 @@
|
|
|
8175
8153
|
this.spineItemsManager = spineItemsManager;
|
|
8176
8154
|
this.context = context;
|
|
8177
8155
|
this.settings = settings;
|
|
8178
|
-
this.itemLayoutInformation = [];
|
|
8179
8156
|
this.layoutSubject = new rxjs.Subject();
|
|
8180
8157
|
spineItemsManager.items$.pipe(
|
|
8181
8158
|
rxjs.switchMap((items) => {
|
|
@@ -8217,7 +8194,6 @@
|
|
|
8217
8194
|
rxjs.exhaustMap(() => {
|
|
8218
8195
|
layoutInProgress.next(true);
|
|
8219
8196
|
const manifest = this.context.manifest;
|
|
8220
|
-
const newItemLayoutInformation = [];
|
|
8221
8197
|
const isGloballyPrePaginated = isFullyPrePaginated(manifest) ?? false;
|
|
8222
8198
|
return rxjs.from(this.spineItemsManager.items).pipe(
|
|
8223
8199
|
rxjs.reduce(
|
|
@@ -8231,31 +8207,22 @@
|
|
|
8231
8207
|
item,
|
|
8232
8208
|
settings: this.settings,
|
|
8233
8209
|
spineItemsManager: this.spineItemsManager,
|
|
8234
|
-
verticalOffset
|
|
8235
|
-
newItemLayoutInformation
|
|
8210
|
+
verticalOffset
|
|
8236
8211
|
})
|
|
8237
8212
|
)
|
|
8238
8213
|
),
|
|
8239
8214
|
rxjs.of({ horizontalOffset: 0, verticalOffset: 0 })
|
|
8240
8215
|
),
|
|
8241
8216
|
rxjs.concatMap((layout$) => layout$),
|
|
8242
|
-
rxjs.
|
|
8243
|
-
|
|
8244
|
-
(old, index) => !shared.isShallowEqual(old, newItemLayoutInformation[index])
|
|
8245
|
-
);
|
|
8246
|
-
this.itemLayoutInformation = newItemLayoutInformation;
|
|
8247
|
-
Report.log(NAMESPACE, `layout`, {
|
|
8248
|
-
hasChanged,
|
|
8249
|
-
itemLayoutInformation: this.itemLayoutInformation
|
|
8250
|
-
});
|
|
8251
|
-
return { hasChanged };
|
|
8217
|
+
rxjs.tap(() => {
|
|
8218
|
+
Report.log(NAMESPACE, `layout`);
|
|
8252
8219
|
}),
|
|
8253
8220
|
rxjs.finalize(() => {
|
|
8254
8221
|
layoutInProgress.next(false);
|
|
8255
8222
|
})
|
|
8256
8223
|
);
|
|
8257
8224
|
}),
|
|
8258
|
-
rxjs.map((
|
|
8225
|
+
rxjs.map(() => {
|
|
8259
8226
|
const items = spineItemsManager.items;
|
|
8260
8227
|
const spineItemsPagesAbsolutePositions = items.map((item) => {
|
|
8261
8228
|
const itemLayout = this.getAbsolutePositionOf(item);
|
|
@@ -8296,7 +8263,6 @@
|
|
|
8296
8263
|
[]
|
|
8297
8264
|
);
|
|
8298
8265
|
return {
|
|
8299
|
-
hasChanged,
|
|
8300
8266
|
spineItemsAbsolutePositions: items.map(
|
|
8301
8267
|
(item) => this.getAbsolutePositionOf(item)
|
|
8302
8268
|
),
|
|
@@ -8314,12 +8280,9 @@
|
|
|
8314
8280
|
layout() {
|
|
8315
8281
|
this.layoutSubject.next(void 0);
|
|
8316
8282
|
}
|
|
8317
|
-
/**
|
|
8318
|
-
* It's important to not use x,y since we need the absolute position of each element. Otherwise x,y would be relative to
|
|
8319
|
-
* current window (viewport).
|
|
8320
|
-
*/
|
|
8321
8283
|
getAbsolutePositionOf(spineItemOrIndex) {
|
|
8322
|
-
|
|
8284
|
+
var _a;
|
|
8285
|
+
return ((_a = this.spineItemsManager.get(spineItemOrIndex)) == null ? void 0 : _a.layoutPosition) || {
|
|
8323
8286
|
left: 0,
|
|
8324
8287
|
right: 0,
|
|
8325
8288
|
top: 0,
|
|
@@ -8329,10 +8292,6 @@
|
|
|
8329
8292
|
x: 0,
|
|
8330
8293
|
y: 0
|
|
8331
8294
|
};
|
|
8332
|
-
const spineItem = this.spineItemsManager.get(spineItemOrIndex);
|
|
8333
|
-
const indexOfItem = spineItem ? this.spineItemsManager.items.indexOf(spineItem) : -1;
|
|
8334
|
-
const layoutInformation = this.itemLayoutInformation[indexOfItem];
|
|
8335
|
-
return layoutInformation || fallback;
|
|
8336
8295
|
}
|
|
8337
8296
|
destroy() {
|
|
8338
8297
|
super.destroy();
|
|
@@ -8457,6 +8416,35 @@
|
|
|
8457
8416
|
const adjustedValue = multiplier * pageSize;
|
|
8458
8417
|
return Math.max(adjustedValue, pageSize);
|
|
8459
8418
|
}
|
|
8419
|
+
/**
|
|
8420
|
+
* Returns the absolute layout position relative to the parent element which
|
|
8421
|
+
* is supposedly and expectedly the spine element.
|
|
8422
|
+
*
|
|
8423
|
+
* @important
|
|
8424
|
+
*
|
|
8425
|
+
* This method is stable and does not consider scalings or transforms on the parents.
|
|
8426
|
+
*
|
|
8427
|
+
* It does assume and requires that:
|
|
8428
|
+
* - the navigator element and the spine element are direct parents.
|
|
8429
|
+
* - the spine items are correctly positioned in the DOM and with correct styles values.
|
|
8430
|
+
*/
|
|
8431
|
+
get layoutPosition() {
|
|
8432
|
+
const left = Math.round(this.containerElement.offsetLeft * 10) / 10;
|
|
8433
|
+
const top = Math.round(this.containerElement.offsetTop * 10) / 10;
|
|
8434
|
+
const width = Math.round(this.containerElement.offsetWidth * 10) / 10;
|
|
8435
|
+
const height = Math.round(this.containerElement.offsetHeight * 10) / 10;
|
|
8436
|
+
const normalizedValues = {
|
|
8437
|
+
left,
|
|
8438
|
+
top,
|
|
8439
|
+
right: left + width,
|
|
8440
|
+
bottom: top + height,
|
|
8441
|
+
x: left,
|
|
8442
|
+
y: top,
|
|
8443
|
+
width,
|
|
8444
|
+
height
|
|
8445
|
+
};
|
|
8446
|
+
return normalizedValues;
|
|
8447
|
+
}
|
|
8460
8448
|
}
|
|
8461
8449
|
class DefaultRenderer extends DocumentRenderer {
|
|
8462
8450
|
onUnload() {
|
|
@@ -8504,17 +8492,6 @@
|
|
|
8504
8492
|
this.unload = () => {
|
|
8505
8493
|
this.renderer.unload();
|
|
8506
8494
|
};
|
|
8507
|
-
this.getElementDimensions = () => {
|
|
8508
|
-
const rect = this.containerElement.getBoundingClientRect();
|
|
8509
|
-
const normalizedValues = {
|
|
8510
|
-
...rect,
|
|
8511
|
-
// we want to round to first decimal because it's possible to have half pixel
|
|
8512
|
-
// however browser engine can also gives back x.yyyy based on their precision
|
|
8513
|
-
width: Math.round(rect.width * 10) / 10,
|
|
8514
|
-
height: Math.round(rect.height * 10) / 10
|
|
8515
|
-
};
|
|
8516
|
-
return normalizedValues;
|
|
8517
|
-
};
|
|
8518
8495
|
this.destroy = () => {
|
|
8519
8496
|
super.destroy();
|
|
8520
8497
|
this.containerElement.remove();
|
|
@@ -8584,6 +8561,9 @@
|
|
|
8584
8561
|
get readingDirection() {
|
|
8585
8562
|
return this.renderer.readingDirection;
|
|
8586
8563
|
}
|
|
8564
|
+
get layoutPosition() {
|
|
8565
|
+
return this.spineItemLayout.layoutPosition;
|
|
8566
|
+
}
|
|
8587
8567
|
get loaded$() {
|
|
8588
8568
|
return this.renderer.state$.pipe(
|
|
8589
8569
|
operators.distinctUntilChanged(),
|