@chayns-components/core
Version:
A set of beautiful React components for developing your own applications with chayns.
47 lines (46 loc) • 1.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useUsableHeight = exports.getUsableHeight = void 0;
var _chaynsApi = require("chayns-api");
const getUsableHeight = async () => {
let usableHeight;
const {
bottomBarHeight,
offsetTop,
windowHeight
} = await (0, _chaynsApi.getWindowMetrics)();
usableHeight = windowHeight;
if (bottomBarHeight) {
usableHeight -= bottomBarHeight;
}
if (offsetTop) {
usableHeight -= offsetTop;
}
return usableHeight;
};
exports.getUsableHeight = getUsableHeight;
const useUsableHeight = ({
shouldReduceByCoverHeight
} = {}) => {
let usableHeight;
const {
bottomBarHeight,
offsetTop,
topBarHeight,
windowHeight
} = (0, _chaynsApi.useWindowMetrics)();
usableHeight = windowHeight;
if (bottomBarHeight) {
usableHeight -= bottomBarHeight;
}
if (!shouldReduceByCoverHeight && topBarHeight) {
usableHeight -= topBarHeight;
} else if (shouldReduceByCoverHeight && offsetTop) {
usableHeight -= offsetTop;
}
return usableHeight;
};
exports.useUsableHeight = useUsableHeight;
//# sourceMappingURL=pageProvider.js.map