-
Notifications
You must be signed in to change notification settings - Fork 17
/
Material.vue
129 lines (123 loc) · 3.06 KB
/
Material.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<template>
<div class="flex items-center justify-center h-screen">
<Flipper :flip-key="toggled">
<div class="phone shadow bg-white relative">
<div class="screen bg-grey"></div>
<div class="body bg-red"></div>
<Flipped flip-id="fab" v-if="!toggled">
<div
tabindex="0"
ref="showSlidePanel"
@click="toggle"
@keyup.enter="toggle"
role="button"
class="fab bg-pink w-16 h-16 rounded-full absolute"
></div>
</Flipped>
<Flipped flip-id="fab" v-if="toggled" @on-complete="handleEnter">
<div role="button" class="bg-pink w-full h-full pin absolute overflow-hidden">
<transition @enter="handleSlidePanelLoaded" @leave="handleSlidePanelOut">
<div
v-if="slidePanelLoaded"
class="bg-white absolute w-full pin-b white-slide-panel p-4"
>
<div class="w-full flex items-end h-full">
<div class="flex flex-col w-full">
<div class="h-10 bg-grey-light w-full mb-4"></div>
<div class="h-10 bg-grey-light w-full mb-4"></div>
<button
ref="hideSlidePanel"
@click="hideSlidePanel"
class="bg-green h-10 w-full"
></button>
</div>
</div>
</div>
</transition>
</div>
</Flipped>
</div>
</Flipper>
</div>
</template>
<script>
import Flipper from "../src/Flipper";
import Flipped from "../src/Flipped";
import anime from "animejs";
export default {
name: "material",
components: {
Flipper,
Flipped
},
data() {
return {
toggled: false,
slidePanelLoaded: false
};
},
methods: {
toggle() {
this.toggled = !this.toggled;
},
handleEnter({ el }) {
this.slidePanelLoaded = true;
},
hideSlidePanel() {
this.slidePanelLoaded = false;
},
handleSlidePanelLoaded(el, done) {
anime({
targets: el,
opacity: [0, 1],
translateY: [100, 0],
duration: 400,
easing: "easeOutSine",
complete: () => {
done();
this.$nextTick(() => {
this.$refs.hideSlidePanel.focus();
});
}
});
},
handleSlidePanelOut(el, done) {
anime({
targets: el,
opacity: [1, 0],
translateY: [0, 100],
duration: 400,
easing: "easeOutSine",
complete: () => {
done();
this.toggled = false;
this.$nextTick(() => {
this.$refs.showSlidePanel.focus();
});
}
});
}
}
};
</script>
<style scoped>
.phone {
width: 300px;
height: 500px;
overflow: hidden;
}
.screen {
height: 200px;
z-index: 0;
pointer-events: none;
}
.fab {
right: 16px;
top: calc(200px - 2rem);
}
.white-slide-panel {
height: 40%;
box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.08);
will-change: transform;
}
</style>