In the current version, an element's offset() doesn't take into account its parents' scrollLeft and scrollTop. Those should take that into account, for all elements except the body.
This patch teaches offset() to take scrolling into account. I included a couple tests, but they don't test every possible edge case (negative scroll values, for instance) b/c it didn't seem necessary.
Let me know if it needs more coverage, or if there's some reason we shouldn't be doing this at all.
ps. This is also how jQuery's offset() works, although they use getBoundingClientRect() if possible. I haven't looked into the pros/cons of that approach.
In the current version, an element's
offset()
doesn't take into account its parents'scrollLeft
andscrollTop
. Those should take that into account, for all elements except the body.This patch teaches
offset()
to take scrolling into account. I included a couple tests, but they don't test every possible edge case (negative scroll values, for instance) b/c it didn't seem necessary.Let me know if it needs more coverage, or if there's some reason we shouldn't be doing this at all.
ps. This is also how jQuery's
offset()
works, although they usegetBoundingClientRect()
if possible. I haven't looked into the pros/cons of that approach.