UNPKG

@helpscout/hsds-react

Version:

React component library for Help Scout's Design System

32 lines (27 loc) 835 B
"use strict"; exports.__esModule = true; exports.getComputedClientRect = void 0; // Deprecated /* istanbul ignore file */ var getComputedClientRect = function getComputedClientRect(node, contentWindow) { var defaultRect = { height: 0, left: 0, top: 0 }; if (!node) return defaultRect; var rect = node.getBoundingClientRect(); var height = rect.height, top = rect.top, left = rect.left; // window.scrollY / window.scrollX cannot be modified (or easily mocked) // within JSDOM. Manually tested in the browser, and the calculations are // correct. var computedTop = top + height + contentWindow.scrollY; var computedLeft = left + contentWindow.scrollX; return { left: computedLeft, top: computedTop, height: height }; }; exports.getComputedClientRect = getComputedClientRect;