getBoundingClientRect()
Click this paragraph to read its getBoundingClientRect().left/top
- Zoom in a bit. (Not really required, but it makes the tests easier to follow.
- Click on the paragraph. You’ll see its current offset.
- Scroll down a little bit until the top of the paragraph is just off-screen. Click again.
- If you now see a negative number it’s relative to the VISUAL VIEWPORT.
- If you still see the same number, scroll all the way down the page. Then scroll up until the
paragraph is barely visible. DO NOT scroll up entirely to the top of the page.
- Click the paragraph again. If the number is still the same, it’s relative to the DOCUMENT (which
is an old-fashioned way of saying layout viewport).
- If the number is different it’s relative to the LAYOUT VIEWPORT (modern definition).