-
Notifications
You must be signed in to change notification settings - Fork 3
/
Loading.vue
68 lines (66 loc) · 1.48 KB
/
Loading.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
<template lang="html">
<div
id="appLoading"
class="o-loader js-loader"
:class="{ 'is-loading': loading }"
>
<div ref="loaderBG" class="o-loader__bg js-loader-bg"></div>
<div class="o-loader__anim">
<div class="o-loader__gradients"></div>
</div>
</div>
</template>
<script>
import { gsap } from 'gsap'
export default {
data: () => ({
loading: false
}),
methods: {
scale() {
if (process.client) {
let setSizes = Math.sqrt(
Math.pow(window.innerWidth, 2) + Math.pow(window.innerHeight, 2)
)
return window.innerWidth > window.innerHeight
? setSizes / window.innerWidth
: setSizes / window.innerHeight
}
},
start() {
this.loading = true
if (process.client) {
gsap.to(this.$refs.loaderBG, {
duration: 0.8,
x: window.innerWidth / 2,
y: window.innerHeight / 2,
transformOrigin: '50% 50%',
scale: this.scale,
ease: 'Expo.easeInOut'
})
}
},
finish() {
if (process.client) {
setTimeout(() => {
this.loading = false
gsap.fromTo(
this.$refs.loaderBG,
{
scale: this.scale
},
{
duration: 0.8,
scale: 0,
ease: 'Expo.easeIn'
}
)
}, 1200)
}
}
}
}
</script>
<style lang="scss">
@import '@/assets/scss/loading.scss';
</style>