Skip to content

Commit

Permalink
Merge pull request #1054 from Mitch-At-Work/autoplay-triggered-event
Browse files Browse the repository at this point in the history
[Feat]: Trigger event (autoplay:select) on autoplay index update
  • Loading branch information
davidjerleke authored Nov 8, 2024
2 parents 67a1ac0 + 71a5d47 commit e714441
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/embla-carousel-autoplay/src/components/Autoplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ declare module 'embla-carousel' {
interface EmblaEventListType {
autoplayPlay: 'autoplay:play'
autoplayStop: 'autoplay:stop'
autoplaySelect: 'autoplay:select'
}
}

Expand Down Expand Up @@ -165,6 +166,8 @@ function Autoplay(userOptions: AutoplayOptionsType = {}): AutoplayType {
} else {
emblaApi.scrollTo(0, jump)
}

emblaApi.emit('autoplay:select')
}

const self: AutoplayType = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,11 @@ Once: <BrandPrimaryText>`no`</BrandPrimaryText>
Fires when autoplay stops playing.

---

### autoplay:select

Once: <BrandPrimaryText>`no`</BrandPrimaryText>

Fires directly after autoplay selects a new index.

---

0 comments on commit e714441

Please sign in to comment.