Discovering vue transitions as a newcomer to Vue has been quite an experience. I am currently working on animating a div by moving it up and expanding its width upon clicking, but I'm still wrapping my head around the concept of transitions. Below is a visual representation of my goal along with the accompanying code.
<template>
<div class="hello">
<transition name="slide">
<div class="meal__status">
<a @click="toggle = !toggle; move();" class="meal__status-wrap"></a>
</div>
</transition>
<div v-if="toggle" class="overlay"></div>
</div>
</template>
<script>
export default {
name: "HelloWorld",
data() {
return {
toggle: false
};
},
methods: {
move() {}
}
};
</script>
<style scoped>
.overlay {
background: rgba(0, 0, 0, 0.9);
width: 100%;
height: 100%;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: block;
text-align: center;
transition: opacity 500ms;
opacity: 1;
}
.meal__status-wrap {
background-color: #42b983;
height: 60px;
width: 70px;
display: block;
position: relative;
z-index: 99999;
}
</style>
Here is the link to the Code Sandbox where you can view the implementation https://codesandbox.io/s/awesome-matsumoto-7rlxb?file=/src/components/HelloWorld.vue
This image represents what I have achieved so farhttps://i.sstatic.net/D1aCB.png
And this image showcases the ultimate goal that I am striving for https://i.sstatic.net/dWl5K.png