Debian Codegraph @

packages/popper/src/utils/getBordersSize.js

raw
1 /*
2 * Helper to detect borders of a given element
3 * @method
4 * @memberof Popper.Utils
5 * @param {CSSStyleDeclaration} styles
6 * Result of `getStyleComputedProperty` on the given element
7 * @param {String} axis - `x` or `y`
8 * @return {number} borders - The borders size of the given axis
9 */
10
11 export default function getBordersSize(styles, axis) {
12 const sideA = axis === 'x' ? 'Left' : 'Top';
13 const sideB = sideA === 'Left' ? 'Right' : 'Bottom';
14
15 return (
16 parseFloat(styles[`border${sideA}Width`]) +
17 parseFloat(styles[`border${sideB}Width`])
18 );
19 }