Skip to content

Commit 2b87e19

Browse files
update feature detection on resize observer example
1 parent 567e155 commit 2b87e19

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

resize-observer/resize-observer-text.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ <h1>So what happened?</h1>
6464
</form>
6565
</div>
6666
<script>
67-
if(ResizeObserver) {
67+
if(window.ResizeObserver) {
6868
const h1Elem = document.querySelector('h1');
6969
const pElem = document.querySelector('p');
7070
const divElem = document.querySelector('body > div');
@@ -87,6 +87,7 @@ <h1>So what happened?</h1>
8787
pElem.style.fontSize = Math.max(1, entry.contentRect.width/600) + 'rem';
8888
}
8989
}
90+
console.log('Size changed');
9091
});
9192

9293
resizeObserver.observe(divElem);
@@ -98,6 +99,8 @@ <h1>So what happened?</h1>
9899
resizeObserver.unobserve(divElem);
99100
}
100101
});
102+
} else {
103+
console.log('Resize observer not supported!');
101104
}
102105
</script>
103106
</body>

0 commit comments

Comments
 (0)