Skip to content

Instantly share code, notes, and snippets.

@roshanca
Created September 21, 2020 15:53
Show Gist options
  • Save roshanca/742442eb988abb156b5368dd24591d5d to your computer and use it in GitHub Desktop.
Save roshanca/742442eb988abb156b5368dd24591d5d to your computer and use it in GitHub Desktop.
JS 如何检测元素是否被其他元素覆盖 #js
new IntersectionObserver(
([change]) => {
// 被覆盖就是 false,反之 true
console.log(change.isVisible)
},
{
threshold: [1.0],
delay: 1000,
trackVisibility: true
}
).observe(target)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment