type="animation"> ne fonctionne pas sur <Transition>
Bonjour,
avec ce code la classe '.zoom-leave-active' utilise la durée de la transition alors que j'ai précisé 'type="animation"' dans la balise <Transition>.
ça fonctionne sur la classe 'enter' mais pas sur 'leave'.
Où est l'erreur ?:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| <template>
<button type="button" @click="flag = !flag">Toggle</button>
<transition name="zoom" type="animation">
<h2 v-if="flag">Hello</h2>
</transition>
</template>
<script>
export default {
name: "App",
data() {
return {
flag: false,
};
},
};
</script>
<style>
h2 {
width: 400px;
padding: 20px;
margin: 20px;
color: white;
}
.zoom-enter-active {
animation: zoom-in 3s linear forwards;
/* transition: all 1s linear; */
}
.zoom-leave-active {
animation: zoom-out 3s linear forwards;
transition: all 1s linear;
}
.zoom-enter-from {
opacity: 0;
}
.zoom-leave-to {
opacity: 0;
}
@keyframes zoom-in {
from {
transform: scale(0, 0);
}
to {
transform: scale(1, 1);
}
}
@keyframes zoom-out {
from {
transform: scale(1, 1);
}
to {
transform: scale(0, 0);
}
}
</style> |