Repository navigation
Commit ea1f366
committed
The top's arrival test cannot be a zero-tolerance comparison
Reported in review, and it holds: at the top of the ledger the arrow pointed up and a second
press moved the page by zero pixels.
The landing and the test for it read one number, and the browser does not keep it. The offset is
answered in 1/64px by getBoundingClientRect(); scrollTo() lands on a whole pixel, rounded to
nearest. Landing at 503.7656 therefore puts the reader at 504, and a strict 「greater than
503.7656」 reads that as 「there is more above」.
Measured across viewport widths the gap never reached half a pixel — and it decided the outcome.
The same code froze the control at 1300, 1440, 1100 and 760, and behaved at 897, because 897's offset
lands on a fraction below the nearest integer rather than above it. A defect that only some widths
produce is harder to recognise as one than a defect that always happens.
Rounding the offset up is what 「arrived」 means, rather than a tolerance chosen to cover the
measurement. Rounding down fails the moment the browser rounds up; rounding to nearest is right
only for the rule in force today, and nothing in a green run would say otherwise. Up holds for
all three.
The bottom end is deliberately left alone. Its landing is the end at the top of the viewport while
its test asks whether the end is still below the fold — a whole viewport apart, so no rounding
error reaches across it — and its offset happened to be a whole number at every width tried. That
is why the two ends are treated differently rather than symmetrically.1 parent f8de63d commit ea1f366
1 file changed
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6537 | 6537 | | |
6538 | 6538 | | |
6539 | 6539 | | |
6540 | | - | |
| 6540 | + | |
| 6541 | + | |
| 6542 | + | |
| 6543 | + | |
| 6544 | + | |
| 6545 | + | |
| 6546 | + | |
| 6547 | + | |
| 6548 | + | |
| 6549 | + | |
| 6550 | + | |
| 6551 | + | |
| 6552 | + | |
6541 | 6553 | | |
6542 | 6554 | | |
6543 | 6555 | | |
| |||
0 commit comments