measure-element.ts
1 import type { DOMElement } from './dom.js' 2 3 type Output = { 4 /** 5 * Element width. 6 */ 7 width: number 8 9 /** 10 * Element height. 11 */ 12 height: number 13 } 14 15 /** 16 * Measure the dimensions of a particular `<Box>` element. 17 */ 18 const measureElement = (node: DOMElement): Output => ({ 19 width: node.yogaNode?.getComputedWidth() ?? 0, 20 height: node.yogaNode?.getComputedHeight() ?? 0, 21 }) 22 23 export default measureElement