Created
June 5, 2018 10:03
-
-
Save techkuz/7872539e5d3467fc1d3e07ca9e32c48b to your computer and use it in GitHub Desktop.
left and top positions of element - javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getOffset(el) { | |
el = el.getBoundingClientRect(); | |
return { | |
left: el.left + window.scrollX, | |
top: el.top + window.scrollY | |
} | |
} | |
// https://stackoverflow.com/a/28222246/7127824 | |
// getOffset(element).left | |
// getOffset(element).top |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment