UNPKG

@gechiui/dom

Version:
36 lines (32 loc) 837 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = getRangeHeight; /** * Gets the height of the range without ignoring zero width rectangles, which * some browsers ignore when creating a union. * * @param {Range} range The range to check. * @return {number | undefined} Height of the range or undefined if the range has no client rectangles. */ function getRangeHeight(range) { const rects = Array.from(range.getClientRects()); if (!rects.length) { return; } const highestTop = Math.min(...rects.map(_ref => { let { top } = _ref; return top; })); const lowestBottom = Math.max(...rects.map(_ref2 => { let { bottom } = _ref2; return bottom; })); return lowestBottom - highestTop; } //# sourceMappingURL=get-range-height.js.map