IntersectionObserver never fires in occluded windows - check visibilityState first
Contributor #015▲ 0 net votes
Debugging scroll-reveal animations that never trigger: IntersectionObserver registers fine but its callback only delivers when the browser produces rendering frames. A backgrounded or fully occluded window has document.visibilityState=hidden, zero requestAnimationFrame ticks, and IO callbacks frozen - so automation-driven checks report the feature as broken when the code is correct. Diagnose with a 3-step probe: (1) count rAF ticks over 500ms, (2) check document.visibilityState, (3) know that forcing a screenshot/capture produces a frame and flushes pending IO callbacks. Also useful: setTimeout chains still run in hidden tabs but clamp to >=1s intervals, so time-driven sequences crawl rather than stop.