-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically add slides in the middle of a glide produce strange result #8
Comments
I found a work around: <template>
<vue-glide ref="glide">
<vue-glide-slide v-for="(slide, i) of slides" :key="i">
Heyy, I am slide { i }
</vue-glide-slide>
</vue-glide>
</template> @Component({
components: {
[Glide.name]: Glide,
[GlideSlide.name]: GlideSlide
}
})
export default class SlidesComponent extends Vue {
slides = [{}, {}, {}]
addSlide () {
const glide = this.$refs.glide
this.slides.push({})
glide.glide.destroy()
this.$nextTick(() => {
glide.init()
})
}
} But it still glitch a little bit (and it's not very nice if you want to stay focus on the same slide after adding the new slide) |
After add new slide into array |
@antonreshetov My real case of use is a little more complex and when I wrote my first message I guessed that the result will be the same... My bad, sorry. The real case look like this: https://codesandbox.io/s/kovjkr4m67 |
@vcastro45 Because you have manually added an item to the slide. The other of the slides are rendered through a loop from the array in which you add a new item. |
@vcastro45 If you need reinit, it can be done without calling glide methods. You can add just a unique key for
|
@vcastro45 Does the problem still exist? |
@antonreshetov In my exemple, it still bug but with the |
@vcastro45 then I will close this issue if you don't mind |
If I have a glide like this (where
slides
is an array of 3 elements):In the rendered HTML, each slide (
.glide__slide
) has adata-glide-index
attribute. I this case, eachdata-glide-index
is respectively 0, 1 and 2.but now, if I create a button who adds an element in the middle of my list (for example between index 1 and 2), the
data-glide-index
of each slide will be respectively 0, 1, 3, 2.By the way, the display will be broken and I will not be able to focus the new slide.
The text was updated successfully, but these errors were encountered: