clientY vs pageY
Given a point in the page, clientY
and pageY
are the distances in pixels from the point to the top of viewport and page.
Here, page is the whole rendered page which may have the scrollbars, whereas viewport is the visible part of the page.
┌─────────────────────────────┬─┐◀︎─── Web page ▲
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | pageY
| | | |
├=============================┼─┤ ▲ | ▲
| | | | | |
| | | | | |
| Scroll bar ──────────▶︎| | | | clientY
| | | Browser | |
| | | window | |
| ● Point | | | ▼ ▼
| | | |
| | | |
├=============================┼─┤ ▼
| | |
| | |
| | |
└─────────────────────────────┴─┘