This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The SnapEvent() constructor creates a new SnapEvent object instance.
new SnapEvent(type, init)
typeA string representing the type of event. For scrollsnapchanging events, this is scrollsnapchanging. For scrollsnapchange events, this is scrollsnapchange.
initAn object containing the following properties:
snapTargetBlock OptionalReturns a reference to the element snapped to in the block direction when the event fired, or null if scroll snapping only occurs in the inline direction so no element is snapped to in the block direction.
snapTargetInline OptionalReturns a reference to the element snapped to in the inline direction when the event fired, or null if scroll snapping only occurs in the block direction so no element is snapped to in the inline direction.
A developer would not use this constructor manually. A new SnapEvent object is constructed when a handler is invoked as a result of the scrollsnapchanging or scrollsnapchange events firing.
For example:
mainElem.addEventListener("scrollsnapchange", (event) => {
// …
// Log a SnapEvent object instance to the console
console.log(event);
});
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
SnapEvent |
138 | 138 | No | 122 | No | 138 | No | No | No | No | No | No |
scrollsnapchanging eventscrollsnapchange event
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/SnapEvent/SnapEvent