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: { methods: {
next() { 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() { 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 = () => { 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 = () => { const prev = () => {
activeIndex.value = activeIndex.value === 0 ? 0 : images.value.length - 1; activeIndex.value = activeIndex.value === 0 ? 0 : activeIndex.value - 1;
}; };
<\/script>`, <\/script>`,
data: ` data: `
@ -179,10 +179,10 @@ const prev = () => {
}, },
methods: { methods: {
next() { 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() { prev() {
this.activeIndex = this.activeIndex === 0 ? 0 : this.images.length - 1; this.activeIndex = this.activeIndex === 0 ? 0 : this.activeIndex - 1;
} }
} }
}; };