scrollingElem.addEventListener("scrollsnapchanging", (event) => {
// Set current pending snap target class to "pending"
event.snapTargetBlock.className = "pending";
// Logs the new pending block-direction snap target element
console.log(event.snapTargetBlock);
// Logs null; no inline snapping occurs
console.log(event.snapTargetInline);
});SnapEvent / notebook
SnapEvent
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
scrollingElem.addEventListener("scrollsnapchange", (event) => {
event.snapTargetBlock.className = "selected";
});