scrollend repro — window.scrollTo() never fires scrollend

The window can’t scroll, yet document.documentElement.scrollHeight is still taller than the viewport.

How this page is built — this is the recipe that reproduces the bug: html, body { margin: 0; height: 100%; overflow: hidden }. All visible content lives in a full-viewport inner scroller (#scroller, position: fixed; inset: 0; overflow: auto). A hidden 200vh dummy block sits in body, so the document looks tall even though the window itself can never scroll. A script that checks document.documentElement.scrollHeight to decide whether to call window.scrollTo(0, 0) will keep trying forever — and scrollend never fires.

Live metrics

documentElement.scrollHeight
body.scrollHeight
window.innerHeight
scrollHeight − innerHeight
document.scrollingElement
window.scrollY
#scroller.scrollTop
#scroller.scrollHeight / clientHeight

Controls

Event log

What to look for:

  • window.scrollTo(0, 0) → no scroll, no scrollend on window.
  • …while document.documentElement.scrollHeight > window.innerHeight the whole time (see metrics).
  • The same call against #scroller → fires scrollend immediately.

Why it happens: with html, body { overflow: hidden; height: 100% } the document has no scrolling box — the fixed inner container is the scroller. The dummy block makes the document report a tall scrollHeight, but window.scrollTo() is a no-op, and a no-op scroll never fires scrollend.

The fix in the other project: scroll the element that actually scrolls (the fixed inner container) instead of window, or don’t gate the decision on documentElement.scrollHeight. Toggle “fix mode” to see the window behave like a normal scroller again.