Skip to content

Commit 0c9009d

Browse files
updating resize observer examples to use contentBoxSize
1 parent 3f50e11 commit 0c9009d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

resize-observer/resize-observer-border-radius.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
<script>
2929
const resizeObserver = new ResizeObserver(entries => {
3030
for (let entry of entries) {
31-
entry.target.style.borderRadius = Math.min(100, (entry.contentRect.width/10) +
32-
(entry.contentRect.height/10)) + 'px';
31+
entry.target.style.borderRadius = Math.min(100, (entry.contentBoxSize.inlineSize/10) +
32+
(entry.contentBoxSize.blockSize/10)) + 'px';
3333
}
3434
});
3535

resize-observer/resize-observer-text.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ <h1>So what happened?</h1>
4646

4747
const resizeObserver = new ResizeObserver(entries => {
4848
for (let entry of entries) {
49-
h1Elem.style.fontSize = Math.max(2, entry.contentRect.width/200) + 'rem';
50-
pElem.style.fontSize = Math.max(1.2, entry.contentRect.width/600) + 'rem';
49+
h1Elem.style.fontSize = Math.max(2, entry.contentBoxSize.inlineSize/200) + 'rem';
50+
pElem.style.fontSize = Math.max(1.2, entry.contentBoxSize.inlineSize/600) + 'rem';
5151
}
5252
});
5353

0 commit comments

Comments
 (0)