forked from vuejs/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBetweenElements.vue
60 lines (51 loc) · 1.2 KB
/
BetweenElements.vue
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
60
<script setup>
const { mode } = defineProps(['mode'])
let docState = $ref('saved')
</script>
<template>
<div class="demo transition-demo">
<span style="margin-right: 20px">Click to cycle through states:</span>
<div class="btn-container">
<Transition name="slide-up" :mode="mode">
<button v-if="docState === 'saved'" @click="docState = 'edited'">
Edit
</button>
<button v-else-if="docState === 'edited'" @click="docState = 'editing'">
Save
</button>
<button v-else-if="docState === 'editing'" @click="docState = 'saved'">
Cancel
</button>
</Transition>
</div>
</div>
</template>
<style>
.transition-demo {
display: flex;
align-items: center;
}
.transition-demo .btn-container {
display: inline-block;
position: relative;
height: 36px;
}
.transition-demo button {
position: absolute;
}
.transition-demo button + button {
margin: 0;
}
.transition-demo .slide-up-enter-active,
.transition-demo .slide-up-leave-active {
transition: all 0.25s ease-out;
}
.slide-up-enter-from {
opacity: 0;
transform: translateY(30px);
}
.slide-up-leave-to {
opacity: 0;
transform: translateY(-30px);
}
</style>