Skip to content

Instantly share code, notes, and snippets.

@umkasanki
Last active March 9, 2018 08:44
Show Gist options
  • Save umkasanki/4d01b214a14eb0d8b11ff8d31772466b to your computer and use it in GitHub Desktop.
Save umkasanki/4d01b214a14eb0d8b11ff8d31772466b to your computer and use it in GitHub Desktop.
jQuery offset of element in relation to viewport
photo = $('#photo')
offset = photo.offset()
photoViewportOffsetTop = offset.top - $(document).scrollTop()
photoViewportOffsetLeft = offset.left - $(document).scrollLeft()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment