1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.getBBoxSize = exports.getContainerSize = void 0;
|
4 | const parseInt10 = (d) => (d ? parseInt(d) : 0);
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | function getContainerSize(container) {
|
11 |
|
12 | const style = getComputedStyle(container);
|
13 | const wrapperWidth = container.clientWidth || parseInt10(style.width);
|
14 | const wrapperHeight = container.clientHeight || parseInt10(style.height);
|
15 | const widthPadding = parseInt10(style.paddingLeft) + parseInt10(style.paddingRight);
|
16 | const heightPadding = parseInt10(style.paddingTop) + parseInt10(style.paddingBottom);
|
17 | return {
|
18 | width: wrapperWidth - widthPadding,
|
19 | height: wrapperHeight - heightPadding,
|
20 | };
|
21 | }
|
22 | exports.getContainerSize = getContainerSize;
|
23 |
|
24 |
|
25 |
|
26 | function getBBoxSize(options) {
|
27 | const { height, width, padding = 0, paddingLeft = padding, paddingRight = padding, paddingTop = padding, paddingBottom = padding, margin = 0, marginLeft = margin, marginRight = margin, marginTop = margin, marginBottom = margin, inset = 0, insetLeft = inset, insetRight = inset, insetTop = inset, insetBottom = inset, } = options;
|
28 |
|
29 |
|
30 | const maybeAuto = (padding) => (padding === 'auto' ? 20 : padding);
|
31 | const finalWidth = width -
|
32 | maybeAuto(paddingLeft) -
|
33 | maybeAuto(paddingRight) -
|
34 | marginLeft -
|
35 | marginRight -
|
36 | insetLeft -
|
37 | insetRight;
|
38 | const finalHeight = height -
|
39 | maybeAuto(paddingTop) -
|
40 | maybeAuto(paddingBottom) -
|
41 | marginTop -
|
42 | marginBottom -
|
43 | insetTop -
|
44 | insetBottom;
|
45 | return { width: finalWidth, height: finalHeight };
|
46 | }
|
47 | exports.getBBoxSize = getBBoxSize;
|
48 |
|
\ | No newline at end of file |