-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstripe-lookalike.vue
91 lines (85 loc) · 2.15 KB
/
stripe-lookalike.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<template>
<main>
<div>
<button
class="btn btn-primary"
@click="show = !show">
Show
</button>
</div>
<br><br>
<!--
NOT using <transition> elements... like Stripe did
This is a little easier to debug bc you can inspect the "before"
state where with <transition> its added dynamically so tough to see
-->
<div class="scene pure-css">
<div :class="{'show':show}" class="alert alert-info">
Howdy! How cool is VueJS ?
</div>
</div>
<!--
Use <transition> elements w/ name
-->
<div class="scene transition">
<transition name="swinger">
<div v-show="show" class="alert alert-info">
Howdy! How cool is VueJS ?
</div>
</transition>
</div>
</main>
</template>
<script>
export default {
name: 'Animations',
data() {
return {
show: false,
};
},
};
</script>
<style lang="scss" scoped>
main{
background-color: dodgerblue;
height: 100vh;
}
.alert{
width: 300px;
height: 300px;
background: white;
}
.scene{
perspective: 2000px;
margin-bottom: 2em;
}
/* Pure css */
.scene.pure-css .alert{
opacity: 0;
transform: rotateX(-15deg);
transform-origin: 50% -50px;
transition-property: transform, opacity;
transition-duration: 200ms;
transition-timing-function: ease-out;
&.show{
opacity: 1;
transform: rotateX(0);
}
}
/* Using transitions */
.scene.transition{
.swinger-enter,
.swinger-leave-to{
opacity: 0;
transform: rotateX(-15deg);
transform-origin: 50% -50px;
}
.swinger-enter-active,
.swinger-leave-active{
transition-property: transform, opacity;
transition-duration: 200ms;
transition-timing-function: ease-out;
}
}
</style>