@jsenv/dom 0.17.3 → 0.17.4
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/jsenv_dom.js +37 -16
- package/package.json +1 -1
package/dist/jsenv_dom.js
CHANGED
|
@@ -7029,24 +7029,45 @@ const getScrollport = (scrollBox, scrollContainer) => {
|
|
|
7029
7029
|
};
|
|
7030
7030
|
};
|
|
7031
7031
|
|
|
7032
|
-
|
|
7032
|
+
/**
|
|
7033
|
+
* Returns [verticalScrollbarWidth, horizontalScrollbarHeight] as currently
|
|
7034
|
+
* rendered by `scrollableElement`, in px. Returns zeros when the element has no
|
|
7035
|
+
* classic scrollbar: no overflow, overlay scrollbars, `scrollbar-width: none`,
|
|
7036
|
+
* or a `::-webkit-scrollbar { display: none }` rule.
|
|
7037
|
+
*
|
|
7038
|
+
* The measurement is taken on the element itself (its own border box versus its
|
|
7039
|
+
* own content box) rather than on a probe node appended inside it. A probe
|
|
7040
|
+
* cannot answer this question: `scrollbar-width` and `::-webkit-scrollbar` are
|
|
7041
|
+
* not inherited, so a probe reports the platform default scrollbar size even
|
|
7042
|
+
* when the element renders no scrollbar at all.
|
|
7043
|
+
*/
|
|
7033
7044
|
const measureScrollbar = (scrollableElement) => {
|
|
7034
|
-
|
|
7035
|
-
scrollableElement
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
|
|
7039
|
-
|
|
7040
|
-
|
|
7041
|
-
|
|
7042
|
-
|
|
7043
|
-
|
|
7044
|
-
|
|
7045
|
-
|
|
7046
|
-
scrollableElement
|
|
7045
|
+
if (
|
|
7046
|
+
scrollableElement === document.documentElement ||
|
|
7047
|
+
scrollableElement === document.scrollingElement
|
|
7048
|
+
) {
|
|
7049
|
+
// documentElement.clientWidth/Height report the viewport minus its
|
|
7050
|
+
// scrollbars, not this element's own box (which `max-width` can shrink), so
|
|
7051
|
+
// the border box to compare against is the window itself.
|
|
7052
|
+
return [
|
|
7053
|
+
snapToPixel(window.innerWidth - document.documentElement.clientWidth),
|
|
7054
|
+
snapToPixel(window.innerHeight - document.documentElement.clientHeight),
|
|
7055
|
+
];
|
|
7056
|
+
}
|
|
7057
|
+
const { left, right, top, bottom } = getBorderSizes(scrollableElement);
|
|
7058
|
+
const scrollbarWidth =
|
|
7059
|
+
scrollableElement.offsetWidth -
|
|
7060
|
+
scrollableElement.clientWidth -
|
|
7061
|
+
left -
|
|
7062
|
+
right;
|
|
7063
|
+
const scrollbarHeight =
|
|
7064
|
+
scrollableElement.offsetHeight -
|
|
7065
|
+
scrollableElement.clientHeight -
|
|
7066
|
+
top -
|
|
7067
|
+
bottom;
|
|
7047
7068
|
return [
|
|
7048
|
-
|
|
7049
|
-
|
|
7069
|
+
scrollbarWidth > 0 ? snapToPixel(scrollbarWidth) : 0,
|
|
7070
|
+
scrollbarHeight > 0 ? snapToPixel(scrollbarHeight) : 0,
|
|
7050
7071
|
];
|
|
7051
7072
|
};
|
|
7052
7073
|
|