Fix controlled demo clicks

pull/4295/head^2
Tuğçe Küçükoğlu 2023-08-18 14:49:38 +03:00
parent d50ebae1e5
commit 7b09579d2c
1 changed files with 6 additions and 6 deletions

View File

@ -103,10 +103,10 @@ export default {
},
methods: {
next() {
this.activeIndex = this.activeIndex === this.images.length - 1 ? 0 : this.activeIndex + 1;
this.activeIndex = this.activeIndex === this.images.length - 1 ? this.images.length - 1 : this.activeIndex + 1;
},
prev() {
this.activeIndex = this.activeIndex === 0 ? 0 : this.images.length - 1;
this.activeIndex = this.activeIndex === 0 ? 0 : this.activeIndex - 1;
}
}
};
@ -155,10 +155,10 @@ const responsiveOptions = ref([
]);
const next = () => {
activeIndex.value = activeIndex.value === images.value.length - 1 ? 0 : activeIndex.value + 1;
activeIndex.value = activeIndex.value === images.value.length - 1 ? images.value.length - 1 : activeIndex.value + 1;
};
const prev = () => {
activeIndex.value = activeIndex.value === 0 ? 0 : images.value.length - 1;
activeIndex.value = activeIndex.value === 0 ? 0 : activeIndex.value - 1;
};
<\/script>`,
data: `
@ -179,10 +179,10 @@ const prev = () => {
},
methods: {
next() {
this.activeIndex = this.activeIndex === this.images.length - 1 ? 0 : this.activeIndex + 1;
this.activeIndex = this.activeIndex === this.images.length - 1 ? this.images.length - 1 : this.activeIndex + 1;
},
prev() {
this.activeIndex = this.activeIndex === 0 ? 0 : this.images.length - 1;
this.activeIndex = this.activeIndex === 0 ? 0 : this.activeIndex - 1;
}
}
};