@absolutejs/beacon 0.6.31 → 0.6.32
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 +15 -7
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2888,18 +2888,25 @@ var createBeacon = (options) => {
|
|
|
2888
2888
|
});
|
|
2889
2889
|
}
|
|
2890
2890
|
if (signals.scrollJail !== false) {
|
|
2891
|
+
const MODAL_SCROLL_OWNER_SELECTOR = '[aria-modal="true"], dialog[open]';
|
|
2892
|
+
const isScrollable = (node) => {
|
|
2893
|
+
const overflowY = window.getComputedStyle(node).overflowY;
|
|
2894
|
+
return (overflowY === "auto" || overflowY === "scroll") && node.scrollHeight > node.clientHeight + 1;
|
|
2895
|
+
};
|
|
2891
2896
|
const nearestScrollable = (start) => {
|
|
2892
2897
|
let node = start;
|
|
2893
2898
|
while (node !== null && node !== document.body) {
|
|
2894
|
-
|
|
2895
|
-
const overflowY = style.overflowY;
|
|
2896
|
-
if ((overflowY === "auto" || overflowY === "scroll") && node.scrollHeight > node.clientHeight + 1) {
|
|
2899
|
+
if (isScrollable(node))
|
|
2897
2900
|
return node;
|
|
2898
|
-
}
|
|
2899
2901
|
node = node.parentElement;
|
|
2900
2902
|
}
|
|
2901
2903
|
return null;
|
|
2902
2904
|
};
|
|
2905
|
+
const modalOwnedScroller = (modal) => {
|
|
2906
|
+
const candidates = Array.from(modal.querySelectorAll("*")).filter(isScrollable);
|
|
2907
|
+
const outermost = candidates.filter((candidate) => !candidates.some((other) => other !== candidate && other.contains(candidate)));
|
|
2908
|
+
return outermost.length === 1 ? outermost[0] ?? null : null;
|
|
2909
|
+
};
|
|
2903
2910
|
let jailBurst = [];
|
|
2904
2911
|
let jailScroller = null;
|
|
2905
2912
|
let jailSettleTimer;
|
|
@@ -2922,7 +2929,8 @@ var createBeacon = (options) => {
|
|
|
2922
2929
|
return;
|
|
2923
2930
|
}
|
|
2924
2931
|
const target = event.target instanceof Element ? event.target : null;
|
|
2925
|
-
const
|
|
2932
|
+
const modal = target?.closest(MODAL_SCROLL_OWNER_SELECTOR) ?? null;
|
|
2933
|
+
const scroller = nearestScrollable(target) ?? (modal === null ? null : modalOwnedScroller(modal)) ?? document.scrollingElement;
|
|
2926
2934
|
if (!(scroller instanceof Element)) {
|
|
2927
2935
|
jailBurst = [];
|
|
2928
2936
|
return;
|
|
@@ -2962,7 +2970,7 @@ var createBeacon = (options) => {
|
|
|
2962
2970
|
const canStillMove = scrollingDown ? scroller.scrollTop + scroller.clientHeight < scroller.scrollHeight - SCROLL_JAIL_BOUNDARY_TOLERANCE_PX : scroller.scrollTop > SCROLL_JAIL_BOUNDARY_TOLERANCE_PX;
|
|
2963
2971
|
if (!canStillMove)
|
|
2964
2972
|
return;
|
|
2965
|
-
if (viewportCoveredByOverlay())
|
|
2973
|
+
if (viewportCoveredByOverlay() && (modal === null || !modal.contains(scroller)))
|
|
2966
2974
|
return;
|
|
2967
2975
|
const descriptor = describeElement(scroller);
|
|
2968
2976
|
if (reportedScrollers.has(descriptor))
|
|
@@ -3955,5 +3963,5 @@ export {
|
|
|
3955
3963
|
BEACON_ATTRIBUTE
|
|
3956
3964
|
};
|
|
3957
3965
|
|
|
3958
|
-
//# debugId=
|
|
3966
|
+
//# debugId=1440495DE8455F0364756E2164756E21
|
|
3959
3967
|
//# sourceMappingURL=index.js.map
|