react-phylogeny-tree-gl
Version:
React integration of phylocanvas.gl. Component and hook for phylogenetic tree visualistion.
21 lines • 839 B
JavaScript
import { useEffect } from 'react';
export function useAutoResize(getTree) {
useEffect(() => {
function updateWidthAndHeight() {
var _a, _b;
const tree = getTree();
if (tree) {
const width = (_a = tree.view.parentElement) === null || _a === void 0 ? void 0 : _a.clientWidth;
const height = (_b = tree.view.parentElement) === null || _b === void 0 ? void 0 : _b.clientHeight;
if (width && height) {
tree.resize(width, height);
}
}
}
window.addEventListener('resize', updateWidthAndHeight);
return function cleanUpAutoResize() {
window.removeEventListener('resize', updateWidthAndHeight);
};
}, [getTree]);
}
//# sourceMappingURL=useAutoResize.js.map