Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
45 lines (42 sloc) 1.13 KB
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Resize observer border-radius test</title>
<style>
html {
height: 100%;
}
body {
height: inherit;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
}
div {
background-color: green;
width: 50%;
height: 50%;
}
</style>
</head>
<body>
<div>
</div>
<script>
const resizeObserver = new ResizeObserver(entries => {
for (let entry of entries) {
if(entry.contentBoxSize) {
entry.target.style.borderRadius = Math.min(100, (entry.contentBoxSize.inlineSize/10) +
(entry.contentBoxSize.blockSize/10)) + 'px';
} else {
entry.target.style.borderRadius = Math.min(100, (entry.contentRect.width/10) +
(entry.contentRect.height/10)) + 'px';
}
}
});
resizeObserver.observe(document.querySelector('div'));
</script>
</body>
</html>
You can’t perform that action at this time.