Answer the question
In order to leave comments, you need to log in
Why doesn't the animation fire when an element appears in the list?
Good afternoon.
Made a slider in vue js.
When clicking on the arrows, the element whose index in the array is equal to currentSlide is shown.
<transition-group tag="div" class="single-estate-planimetry__slider" name="planslider" appear>
<div v-if="index === currentPlanimetry" :data-index="index" class="single-estate__descr-img" v-for="(item, index) in planimetry" :key="item.nome">
<img :src="item.nome" :alt="item.title">
</div>
</transition-group>
const appSingle = new Vue({
el: "#app-single",
data() {
return {
planimetry: [],
currentPlanimetry: 0
}
},
methods: {
prevPlanimetry(){
if (this.currentPlanimetry === 0) {
this.currentPlanimetry = this.planimetry.length - 1
} else {
this.currentPlanimetry--
}
},
nextPlanimetry(){
if (this.currentPlanimetry === this.planimetry.length - 1) {
this.currentPlanimetry = 0
} else {
this.currentPlanimetry++
}
},
}
});
.planslider-enter-from {
opacity: 0;
}
.planslider-enter-to {
opacity: 1;
}
.planslider-enter-active {
transition: all 3s;
}
.planslider-leave-from {
opacity: 1;
}
.planslider-leave-to {
opacity: 0;
}
.planslider-leave-active {
//transition: all 3s;
}
Answer the question
In order to leave comments, you need to log in
Judging by
const appSingle = new Vue({
.planslider-enter-from {
.planslider-leave-from {
<transition-group tag="div" class="single-estate-planimetry__slider" name="planslider" appear> <div v-if="index === currentPlanimetry" :data-index="index" class="single-estate__descr-img" v-for="(item, index) in planimetry" :key="item.nome">
transition-group
with transition
. Remove v-if
and v-for
. Make a computed property that represents the current element.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question