@autoguru/overdrive 4.15.1 → 4.15.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWindowHeightFill.d.ts","sourceRoot":"","sources":["../../../lib/hooks/useWindowHeightFill/useWindowHeightFill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"useWindowHeightFill.d.ts","sourceRoot":"","sources":["../../../lib/hooks/useWindowHeightFill/useWindowHeightFill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAqC,MAAM,OAAO,CAAC;AAIrE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,MAAM,WAAW,wBAAwB;IACxC,SAAS,CAAC,EAAE,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;IAClC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,YAAY,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IACxC,kBAAkB,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;CAC/C;AAED,eAAO,MAAM,mBAAmB,sFAM7B,wBAAwB,KAAG,MA8D7B,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { useLayoutEffect, useState } from 'react';
|
|
3
|
+
import { useLayoutEffect, useRef, useState } from 'react';
|
|
4
4
|
import { useResponsiveValue, useTheme } from "../../index.js";
|
|
5
5
|
import { themeContractVars } from "../../themes/theme.css.js";
|
|
6
6
|
import { getThemeTokenValue } from "../../utils/css.js";
|
|
@@ -18,16 +18,26 @@ export const useWindowHeightFill = _ref => {
|
|
|
18
18
|
themeClass
|
|
19
19
|
} = useTheme();
|
|
20
20
|
const [containerHeight, setContainerHeight] = useState("".concat(serverVhFallback, "vh"));
|
|
21
|
+
const containerHeightRef = useRef(containerHeight);
|
|
21
22
|
useLayoutEffect(() => {
|
|
22
23
|
var _window, _document;
|
|
23
24
|
if (!(containerRef !== null && containerRef !== void 0 && containerRef.current) || !((_window = window) !== null && _window !== void 0 && _window.innerHeight) || !((_document = document) !== null && _document !== void 0 && _document.body)) return void 0;
|
|
24
25
|
const resize = () => {
|
|
25
26
|
const gap = getThemeTokenValue(themeClass, themeContractVars.space[bottomGap]) || '0px';
|
|
26
27
|
const availableHeight = window.innerHeight - containerRef.current.getBoundingClientRect().top;
|
|
27
|
-
|
|
28
|
+
const newHeight = gap ? "calc(".concat(availableHeight, "px - ").concat(gap, ")") : "".concat(availableHeight, "px");
|
|
29
|
+
if (containerHeightRef.current !== newHeight) {
|
|
30
|
+
setContainerHeight(newHeight);
|
|
31
|
+
containerHeightRef.current = newHeight;
|
|
32
|
+
}
|
|
28
33
|
};
|
|
29
34
|
const mutationObserver = new MutationObserver(resize);
|
|
30
|
-
mutationObserver.observe((observedElementRef === null || observedElementRef === void 0 ? void 0 : observedElementRef.current) || document.body
|
|
35
|
+
mutationObserver.observe((observedElementRef === null || observedElementRef === void 0 ? void 0 : observedElementRef.current) || document.body, {
|
|
36
|
+
childList: true,
|
|
37
|
+
subtree: true,
|
|
38
|
+
attributes: false,
|
|
39
|
+
characterData: false
|
|
40
|
+
});
|
|
31
41
|
const resizeObserver = new ResizeObserver(resize);
|
|
32
42
|
resizeObserver.observe((observedElementRef === null || observedElementRef === void 0 ? void 0 : observedElementRef.current) || document.body);
|
|
33
43
|
window.removeEventListener('resize', resize);
|