@eric-emg/symphiq-components 1.2.100 → 1.2.101
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.
|
@@ -24966,6 +24966,7 @@ class FloatingTocComponent {
|
|
|
24966
24966
|
this.setupIntersectionObserver();
|
|
24967
24967
|
this.calculateContainerOffset();
|
|
24968
24968
|
this.setupResizeListener();
|
|
24969
|
+
this.setupScrollListener();
|
|
24969
24970
|
}
|
|
24970
24971
|
}
|
|
24971
24972
|
ngOnDestroy() {
|
|
@@ -24975,6 +24976,9 @@ class FloatingTocComponent {
|
|
|
24975
24976
|
if (this.resizeListener && typeof window !== 'undefined') {
|
|
24976
24977
|
window.removeEventListener('resize', this.resizeListener);
|
|
24977
24978
|
}
|
|
24979
|
+
if (this.scrollListener && typeof window !== 'undefined') {
|
|
24980
|
+
window.removeEventListener('scroll', this.scrollListener, true);
|
|
24981
|
+
}
|
|
24978
24982
|
}
|
|
24979
24983
|
setupIntersectionObserver() {
|
|
24980
24984
|
this.observer = new IntersectionObserver((entries) => {
|
|
@@ -25070,11 +25074,19 @@ class FloatingTocComponent {
|
|
|
25070
25074
|
};
|
|
25071
25075
|
window.addEventListener('resize', this.resizeListener);
|
|
25072
25076
|
}
|
|
25077
|
+
setupScrollListener() {
|
|
25078
|
+
this.scrollListener = () => {
|
|
25079
|
+
this.calculateContainerOffset();
|
|
25080
|
+
};
|
|
25081
|
+
window.addEventListener('scroll', this.scrollListener, { passive: true });
|
|
25082
|
+
}
|
|
25073
25083
|
calculateContainerOffset() {
|
|
25074
25084
|
if (this.embedded && this.containerElement) {
|
|
25075
25085
|
const rect = this.containerElement.getBoundingClientRect();
|
|
25076
|
-
const
|
|
25077
|
-
|
|
25086
|
+
const stickyHeader = document.querySelector('header');
|
|
25087
|
+
const headerHeight = stickyHeader ? stickyHeader.getBoundingClientRect().height : 0;
|
|
25088
|
+
const viewportOffset = Math.max(0, rect.top);
|
|
25089
|
+
this.containerTopOffset.set(viewportOffset + headerHeight);
|
|
25078
25090
|
}
|
|
25079
25091
|
else {
|
|
25080
25092
|
this.containerTopOffset.set(0);
|
|
@@ -25082,7 +25094,7 @@ class FloatingTocComponent {
|
|
|
25082
25094
|
}
|
|
25083
25095
|
getCalculatedTopPosition() {
|
|
25084
25096
|
if (this.embedded && this.containerTopOffset() > 0) {
|
|
25085
|
-
return this.
|
|
25097
|
+
return this.containerTopOffset() + 16;
|
|
25086
25098
|
}
|
|
25087
25099
|
return this.BASE_OFFSET;
|
|
25088
25100
|
}
|