Skip to content

Instantly share code, notes, and snippets.

@jimyuan
Created July 5, 2018 06:33
Show Gist options
  • Save jimyuan/f0be1562b9d832e6cc166450ba341f09 to your computer and use it in GitHub Desktop.
Save jimyuan/f0be1562b9d832e6cc166450ba341f09 to your computer and use it in GitHub Desktop.
Object in viewport
var top = obj.getBoundingClientRect().top //元素顶端到可见区域顶端的距离
var se = document.documentElement.clientHeight //浏览器可见区域高度。
if(top <= se ) {
//code
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment