forked from vuejs/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJsHooks.vue
65 lines (58 loc) · 1.01 KB
/
JsHooks.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
<script setup>
import { ref } from 'vue'
import gsap from 'gsap'
const show = ref(true)
function onBeforeEnter(el) {
gsap.set(el, {
scaleX: 0.25,
scaleY: 0.25,
opacity: 1
})
}
function onEnter(el, done) {
gsap.to(el, {
duration: 1,
scaleX: 1,
scaleY: 1,
ease: 'elastic.inOut(2.5, 1)',
onComplete: done
})
}
function onLeave(el, done) {
gsap.to(el, {
duration: 0.7,
scaleX: 1,
scaleY: 1,
x: 300,
ease: 'elastic.inOut(2.5, 1)'
})
gsap.to(el, {
duration: 0.2,
delay: 0.5,
opacity: 0,
onComplete: done
})
}
</script>
<template>
<div class="demo">
<button @click="show = !show">Toggle</button>
<Transition
@before-enter="onBeforeEnter"
@enter="onEnter"
@leave="onLeave"
:css="false"
>
<div class="gsap-box" v-if="show"></div>
</Transition>
</div>
</template>
<style>
.gsap-box {
background: var(--vt-c-green);
margin-top: 20px;
width: 30px;
height: 30px;
border-radius: 50%;
}
</style>