* Helper function to get the bounds of the bar regardless of the orientation * @param {BarElement} bar the bar * @param {boolean} [useFinalPosition] * @return {object} bounds of the bar * @private
(bar, useFinalPosition)
| 13 | * @private |
| 14 | */ |
| 15 | function getBarBounds(bar, useFinalPosition) { |
| 16 | const {x, y, base, width, height} = /** @type {BarProps} */ (bar.getProps(['x', 'y', 'base', 'width', 'height'], useFinalPosition)); |
| 17 | |
| 18 | let left, right, top, bottom, half; |
| 19 | |
| 20 | if (bar.horizontal) { |
| 21 | half = height / 2; |
| 22 | left = Math.min(x, base); |
| 23 | right = Math.max(x, base); |
| 24 | top = y - half; |
| 25 | bottom = y + half; |
| 26 | } else { |
| 27 | half = width / 2; |
| 28 | left = x - half; |
| 29 | right = x + half; |
| 30 | top = Math.min(y, base); |
| 31 | bottom = Math.max(y, base); |
| 32 | } |
| 33 | |
| 34 | return {left, top, right, bottom}; |
| 35 | } |
| 36 | |
| 37 | function skipOrLimit(skip, value, min, max) { |
| 38 | return skip ? 0 : _limitValue(value, min, max); |
no test coverage detected