I need to get the top position of an element relative to the top of the viewport, not the whole document.
I tried offset().top; which returns the top position relative to the document, and I tried scrollTop() which always returns 0 regardless of the element's visibility in the viewport.