UNPKG

@qntm-code/utils

Version:

A collection of useful utility functions with associated TypeScript types. All functions have been unit tested.

18 lines (17 loc) 612 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getElementWidth = void 0; const constants_1 = require("../constants"); const getComputedStyleAsNumber_1 = require("./getComputedStyleAsNumber"); /** * Get the width of an element. * * This helper allows getting of the width when running in a JSDOM environment. */ function getElementWidth(element) { if (constants_1.isJsdom) { return (0, getComputedStyleAsNumber_1.getComputedStyleAsNumber)(element, 'width'); } return element.getBoundingClientRect().width; } exports.getElementWidth = getElementWidth;