In JavaScript, scrollsnapchanging fires on the document scroll container when the browser decides a new snap target is pending — it will be selected when the current scroll gesture ends (MDN). The document must be the snap container (scroll-snap-type on html).
Register a listener with addEventListener. Check readiness and browser support before you rely on this event.
Syntax
Listen for scrollsnapchanging. Start with this line.
scrollsnapchanging supported — scroll to snap
/* or missing — CSS snap may still work */
How It Works
Probe the handler property."onscrollsnapchanging" in document.
Tell the user. CSS snap can work even when the JS event is missing.
Attach only if supported. Progressive enhancement (MDN guidance).
Keep CSS first. The event is optional UI sugar.
Compatibility
Browser Support
Document scrollsnapchanging is marked Experimental and Limited availability on MDN (not Baseline). Logos use the shared browser-image-sprite.png sprite from this project. Feature-detect and keep CSS snap usable without the event.
✓ Experimental · Limited availability
Document scrollsnapchanging
Fires when a new scroll snap target is pending on the document snap container.
LimitedCheck compat
Google ChromeCheck BCD / Chromium scroll snap events
Partial
Mozilla FirefoxLimited / check BCD
Limited
Apple SafariLimited / check BCD
Limited
Microsoft EdgeFollow Chromium (check BCD)
Partial
OperaFollow Chromium behavior
Partial
Internet ExplorerNo scrollsnapchanging
Not supported
scrollsnapchangingLimited availability
Bottom line: Set scroll-snap-type on html, listen for scrollsnapchanging, read SnapEvent.snapTargetBlock, and feature-detect before production. See the MDN Document scrollsnapchanging reference.
Frequently Asked Questions
It fires on the scroll container when the browser determines a new scroll snap target is pending — it will be selected when the current scroll gesture ends (MDN). The Document must be the snap container (scroll-snap-type on html).
MDN marks Document scrollsnapchanging as Experimental and Limited availability (not Baseline). It is not Deprecated or Non-standard. Feature-detect before production use.
scrollsnapchanging means a snap target is pending during the gesture. scrollsnapchange means a new snap target was selected at the end of the scrolling operation.
A SnapEvent, which inherits from Event. Use event.snapTargetBlock (and snapTargetInline when relevant) for the pending snap target element.
MDN’s example removes old pending classes, then adds pending to event.snapTargetBlock so only the current pending target is highlighted.
Same idea for an Element snap container. Document scrollsnapchanging is for when html is the scroll snap container.