My Vue.js image slider has been set up to loop through 4 images using a setInterval function. It's almost perfect, but I've noticed that there is a delay when the last image is reached and it resets back to the first image. Is there a way to make this transition smoother and quicker?
<script>
export default {
name: "Slider",
data() {
return {
currentSliderIndex: 0
};
},
mounted() {
setInterval(() => {
this.currentSliderIndex = this.currentSliderIndex + 1;
if (this.currentSliderIndex > 4) {
clearInterval();
this.currentSliderIndex = 0;
}
}, 4000);
}
};
</script>