MCPcopy
hub / github.com/marcj/css-element-queries / getElementSize

Function getElementSize

src/ResizeSensor.js:76–89  ·  view source on GitHub ↗

* Get element size * @param {HTMLElement} element * @returns {Object} {width, height}

(element)

Source from the content-addressed store, hash-verified

74 * @returns {Object} {width, height}
75 */
76 function getElementSize(element) {
77 if (!element.getBoundingClientRect) {
78 return {
79 width: element.offsetWidth,
80 height: element.offsetHeight
81 }
82 }
83
84 var rect = element.getBoundingClientRect();
85 return {
86 width: Math.round(rect.width),
87 height: Math.round(rect.height)
88 }
89 }
90
91 /**
92 * Apply CSS styles to element.

Callers 2

attachResizeEventFunction · 0.70
onScrollFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected