vueper-slides icon indicating copy to clipboard operation
vueper-slides copied to clipboard

Autoplay not working

Open sandyrewa opened this issue 3 years ago • 1 comments

I'm using simple image slider with basic example but autoplay not working and getting error on console

Error image: This is error image

Example code:

<vueper-slides autoplay>
<vueper-slide v-for="(slide, i) in slides"
    :key="slide.id"
    :title="slide.title"
    :content="slide.content"
    :style="'background-color: ' + colors[i % 4]" />
</vueper-slides>

sandyrewa avatar Nov 02 '22 11:11 sandyrewa

Confirmation - happening to me as well. Tried to update to latest, still happening across browsers.

On first init of the component the duration check from slide is crashing on undefined even though the property is clearly set up properly. When I clicked out and then reactivated the component, it suddenly started to work - this is reliably reproducible behaviour, so I created rather hacky and ugly, but still working workaround - should somebody be interested in it:

  1. Put following v-if="slideShowHack" on the vueper-slides component.

  2. And then this slideShowHack is set like this using a watch over the slides:

slides: {
      immediate: true,
      handler() {
        this.slideShowHack = false;
        this.$nextTick(() => {
          this.slideShowHack = true;
        });
      },
},

So it is essentially forcing a re-render / re-init of the entire component whenever slides array changes. Obviously - and I cannot stress this enough - this is very hacky and not exactly pretty, but it's a workaround.

To prevent some blinking that this could lead to on initial render of the parent component, set the default value of slideShowHack to false.

martinpokorny avatar Dec 12 '22 15:12 martinpokorny