Refine measurement of scrolling viewport.

Fixes #1.