Skip to content

Commit fbeb392

Browse files
committed
Consider border size in resize observer
1 parent a5de60f commit fbeb392

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/internal/container-queries/use-resize-observer.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,15 @@ function convertElementToEntry(element: Element, rect: DOMRect): ContainerQueryE
8787
const paddingRight = parseFloat(computedStyle.paddingRight) || 0;
8888
const paddingTop = parseFloat(computedStyle.paddingTop) || 0;
8989
const paddingBottom = parseFloat(computedStyle.paddingBottom) || 0;
90+
const borderLeft = parseFloat(computedStyle.borderLeftWidth) || 0;
91+
const borderRight = parseFloat(computedStyle.borderRightWidth) || 0;
92+
const borderTop = parseFloat(computedStyle.borderTopWidth) || 0;
93+
const borderBottom = parseFloat(computedStyle.borderBottomWidth) || 0;
9094

9195
return {
9296
target: element,
93-
contentBoxWidth: rect.width - paddingLeft - paddingRight,
94-
contentBoxHeight: rect.height - paddingTop - paddingBottom,
97+
contentBoxWidth: rect.width - paddingLeft - paddingRight - borderLeft - borderRight,
98+
contentBoxHeight: rect.height - paddingTop - paddingBottom - borderTop - borderBottom,
9599
borderBoxWidth: rect.width,
96100
borderBoxHeight: rect.height,
97101
};

0 commit comments

Comments
 (0)