Now I want to implement when click the button rotate allow icon. down to up, up to down, within the spinning motion.
now my code is the bellow
<template>
<v-btn v-on:click="isShow = !isShow">
<transition name='rotate'>
<v-icon v-if="!isShow">
mdi-menu-down
</v-icon>
</transition>
<v-icon v-show="isShow">
mdi-menu-up
</v-icon>
</v-btn>
</template>
<stlyle scoped>
.rotate-leave-active {
transform: rotate(180deg);
}
.rotate-enter-active {
transform: rotate(180deg);
}
.rotate-enter .rotate-leave-to {
transform: rotate(0deg);
}
.rotate-leave .rotate-enter-to {
transform: rotate(180deg);
}
</style>
Now, when it click the button, The arrow icon will rotate and turn up ward. At this time, two icons will be displayed for a moment.
How can I solve it?
CodePudding user response:
This should help:
new Vue({
el: '#app',
data () {
return {
isShow: false,
}
},
})
.toggleUpDown {
transition: transform .3s ease-in-out !important;
}
.toggleUpDown.rotate {
transform: rotate(180deg);
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material Icons">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.js"></script>
<div id="app">
<v-app>
<div>
<v-btn @click="isShow = !isShow">
{{ isShow ? 'Collapse ' : 'Expand ' }}
<v-icon :class='{ "rotate": isShow }'>arrow_drop_down</v-icon>
</v-btn>
</div>
</v-app>
</div>