---
title: "Scroll Snap Events"
description: "Slides that react the moment they snap, using native scroll snap events."
canonical_url: "https://www.blossom-carousel.com/docs/examples/experimental/scroll-snap-changing"
---

> Index of every page on this site: [llms.txt](https://www.blossom-carousel.com/llms.txt)

<supports-scroll-snap-event-support>
<caution>

Scroll-snap events are not yet supported in this browser. Check browser compatibility at [caniuse.com](https://caniuse.com/?search=scroll-snap-change)

</caution>
</supports-scroll-snap-event-support>

<example-scroll-snap-events>



</example-scroll-snap-events>

<code-group>

```ts [.ts]
const carousel = document.querySelector(".carousel") as HTMLElement;
const videos = carousel.querySelectorAll("video");

carousel.addEventListener("scrollsnapchange", (event) => {
  (event.snapTargetInline as HTMLVideoElement)?.play();
});

carousel.addEventListener("scrollsnapchanging", () => {
  videos.forEach((video) => video.pause());
});
```

```css [.css]
.carousel {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 400px;
  gap: 1rem;
  scroll-snap-type: x mandatory;
}

.slide {
  width: 100%;
  aspect-ratio: 16 / 9;
  scroll-snap-align: center;
  object-fit: cover;
  border-radius: 0.5rem;
}
```

```html [.html]
<BlossomCarousel class="carousel">
  <video
    class="slide"
    src="cat.mp4"
    playsinline
    loop
    muted
    preload="metadata"
  ></video>
  <video
    class="slide"
    src="corgi.mp4"
    playsinline
    loop
    muted
    preload="metadata"
  ></video>
  <video
    class="slide"
    src="bunny.mp4"
    playsinline
    loop
    muted
    preload="metadata"
  ></video>
  ...
</BlossomCarousel>
```

</code-group>

## Sitemap

See the full [sitemap](https://www.blossom-carousel.com/sitemap.md) for all pages.
