ismail9k / vue3-carousel

Vue 3 carousel component
https://ismail9k.github.io/vue3-carousel/
MIT License
666 stars 166 forks source link

Bind next, prev and slideTo to carousel addon slot #241

Closed IsraelOrtuno closed 1 year ago

IsraelOrtuno commented 1 year ago

This would allow to easily use carousel actions without having to deal with a template ref.

<Carousel :settings="{itemsToShow:3.5}">
  <Slide v-for="(course, n) in courses" :key="n">
    <Course :course="course" />
  </Slide>

  <template #addons={ prev, next, slideTo }>
     <button @click="prev">Previous slide</button>
     <button @click="next">Next slide</button>
  </template>
</Carousel>
silvanm commented 1 year ago

For me, this broke my application.

I have something along the lines of this:

<script setup>
const carousel = ref(null);
const next = () => carousel.next()
</script>
<template>
    <Carousel ref="carousel">
       <!-- carousel slides here -->
    </Carousel>
    <button @click="next">
</template>

It stopped working after upgrading to 2.3.5. Anything done wrong on my side?

toyopilgrim commented 1 year ago

This worked on my app using 0.2.5

const carousel = ref(null);
const next = () => carousel.value.next()