In JavaScript, the scrollsnapchanging event fires on a scroll container during a scrolling gesture when the browser decides a new snap target is pending—the one that will be selected when the gesture ends (MDN). The event type is a SnapEvent.
Register a listener with addEventListener. Check readiness and browser support before you rely on this event.
Syntax
Listen for scrollsnapchanging. Start with this line.
JavaScript
el.addEventListener("scrollsnapchanging", fn)
Call
What it does
el.addEventListener("scrollsnapchanging", fn)
Primary signature.
Built into the browser. Listen with el.addEventListener("scrollsnapchanging", …) — no import required.
Library declarations
JavaScript
el.addEventListener("scrollsnapchanging", fn)
Parameters
Parameter
Description
CSS scroll snap
Required. Creates snap targets
Feature detect
Required. Limited / Experimental API
SnapEvent
Required. Pending target element refs
Return Value
Return Value
Description
*
Fires as an Element event (listener receives the Event object).
JavaScript Examples
Example 1 — Feature Detect
Check support before building a pending-snap UI.
JavaScript
const supported = "onscrollsnapchanging" in window;
console.log(supported);
if (!supported) {
console.log("Skip preview highlight; wait for scrollend");
}
Feature-detect first. Avoid attaching on unsupported engines.
Read the target element.snapTargetBlock is an Element reference.
Pull a label. Use data-* or text for a simple message.
Expect repeats. The handler may run several times per gesture.
Compatibility
Browser Support
scrollsnapchanging is marked Experimental and Limited availability on MDN (not Baseline). Support is incomplete — feature-detect and treat pending UI as optional.
✓ Experimental · Limited availability
Element scrollsnapchanging
SnapEvent when a pending scroll snap target is determined during a gesture.
PartialNot Baseline
Google ChromeRecent Chromium (check MDN)
Supported
Mozilla FirefoxOften unavailable
Unavailable
Apple SafariOften unavailable
Unavailable
Microsoft EdgeChromium-based
Supported
OperaChromium-based paths
Partial
Internet ExplorerNot available
Unavailable
scrollsnapchangingLimited
Bottom line: Use progressively: enhance Chromium-class browsers with scrollsnapchanging; fall back to selected-state updates on scrollsnapchange or scrollend elsewhere.
Frequently Asked Questions
It fires on a scroll container during a scrolling gesture when the browser determines a new scroll snap target is pending—the one that will be selected when the gesture ends (MDN).
MDN marks Element scrollsnapchanging as Experimental and Limited availability (not Baseline). It is not Deprecated or Non-standard. Feature-detect before relying on it in production.
A SnapEvent, which inherits from Event. Use snapTargetBlock and/or snapTargetInline to read the pending snap targets for each axis.
Yes. It can fire multiple times as the user moves over potential snap targets. It does not fire for every crossed target—only for the last target the snap would potentially rest on (MDN).
scrollsnapchanging reports the pending target during the gesture. scrollsnapchange fires at the end when a new snap target is actually selected (just before scrollend).
Set scroll-snap-type on the scroll container and scroll-snap-align on child snap targets so the browser has something to snap to.