@dnanpm/styleguide
Version:
DNA Styleguide repository provides the set of components and theme object used in various DNA projects.
26 lines (21 loc) • 915 B
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var React = require('react');
var useDebounce = require('./useDebounce.js');
const DEBOUNCE_DELAY = 100;
const useDocHeight = () => {
const setDocHeight = React.useCallback(() => {
document.documentElement.style.setProperty('--vh100', `${window.innerHeight}px`);
}, []);
const debounceSetDocHeight = useDebounce.default(setDocHeight, DEBOUNCE_DELAY);
React.useEffect(() => {
setDocHeight();
window.addEventListener('resize', debounceSetDocHeight);
window.addEventListener('orientationchange', debounceSetDocHeight);
return () => {
window.removeEventListener('resize', debounceSetDocHeight);
window.removeEventListener('orientationchange', debounceSetDocHeight);
};
}, [debounceSetDocHeight, setDocHeight]);
};
exports.default = useDocHeight;