Automatic update from web-platform-tests WebKit export of https://bugs.webkit.org/show_bug.cgi?id=314778 -- wpt-commits: 1e98f48e81b20e7bf91fcdf6e0a8319558bd6254 wpt-pr: 60041
34 lines
601 B
HTML
34 lines
601 B
HTML
<!DOCTYPE html>
|
|
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
#target {
|
|
position: absolute;
|
|
height: 40px;
|
|
width: 40px;
|
|
background-color: green;
|
|
}
|
|
</style>
|
|
|
|
<div id="target"></div>
|
|
|
|
<script>
|
|
let options = {
|
|
rootMargin: '40px 0px 0px 0px',
|
|
threshold: [1]
|
|
}
|
|
|
|
let observer = new IntersectionObserver((observations) => {
|
|
const lastObservation = observations[observations.length - 1];
|
|
window.top.postMessage({
|
|
isIntersecting: lastObservation.isIntersecting
|
|
}, "*");
|
|
}, options);
|
|
|
|
observer.observe(document.getElementById("target"));
|
|
</script>
|