I'm trying to build a calendar component,and when I click next or prev I want a transition, I also want to add a transition when I slide, but I can't make vue transitions work. I only have one element(current Month) and after I click to go next or prev only thing It does is change the data. To be able to add a dynamic transform: translate, because I need to get mouse position when slide, should I create 3 elements(previous month, current month, next month)? Or can I make that work only changing data?
I tried the most simple example on vue docs and every time I click on the buttons the transition doesnt work.
<transition name="home">
<Calendar></Calendar>
</transition>
.home-enter-active,
.home-leave-active {
transition: opacity 4s;
}
.home-enter,
.home-leave-active {
opacity: 0;
}
And this is my calendar component.
<template>
<div id="calendar" class="calendar">
<div>
<div>{{ state.currentMonthName }}</div>
<div>{{ state.currentYear }}</div>
<div>
<ul class="weekDays">
<li v-for="days in state.weekNames" :key="days">{{ days }}</li>
</ul>
</div>
<div class="days">
<span
@click="
selectDate(state.currentYear, state.currentMonth - 1, state.getLastDayOfPreviousMonth - state.startDay + day);
goPrev();
"
class="lastMonth"
v-for="day in state.startDay"
:key="'empty' + day"
>{{ state.getLastDayOfPreviousMonth - state.startDay + day }}</span
>
<span :class="currenDateClass(state.currentYear, state.currentMonth, day)" @click="selectDate(state.currentYear, state.currentMonth, day)" v-for="day in state.getLastDayOfMonth" :key="day">{{ day }}</span>
<span
@click="
goNext();
selectDate(state.currentYear, state.currentMonth, day);
"
class="lastMonth"
v-for="day in 6 - state.endDay"
:key="'nextMonth' + day"
>{{ day }}</span
>
</div>
</div>
<button @click="goPrev">Prev</button>
<button @click="goNext">Next</button>
</div>
</template>