-
Notifications
You must be signed in to change notification settings - Fork 51
/
index.html
159 lines (142 loc) · 3.43 KB
/
index.html
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*, *:before, *:after {
box-sizing: border-box;
position: relative;
}
body, html {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
.layer {
background: white;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
}
.layer.active {
z-index: 99
}
[data-flip-key] {
width: 4rem;
height: 4rem;
outline: 1px solid blue;
display: inline-block;
}
[data-flip-key].active {
/*width: 8rem;
height: 8rem;*/
position: absolute;
top: 0;
left: 0;
}
.boxes {
display: flex;
flex-direction: row;
flex-wrap: wrap;
width: 8rem;
height: 8rem;
justify-content: space-around;
align-content: space-around;
}
.layer + .layer .boxes {
flex-wrap: wrap-reverse;
}
.layer + .layer [data-flip-key] {
border: 1rem solid blue;
}
.inner {
opacity: 0;
transition: opacity 1s ease;
position: absolute;
}
.active .inner {
opacity: 1;
position: relative;
}
</style>
</head>
<body>
<div class="layer active">
<div class="boxes">
<div data-flip-key="1" style="background-color:red">A</div>
<div data-flip-key="2">C</div>
<div data-flip-key="3">D</div>
<div data-flip-key="4">B</div>
</div>
</div>
<div class="layer">
<div class="boxes">
<div data-flip-key="2">C</div>
<div data-flip-key="1" style="background-color:red">A</div>
<div data-flip-key="4">B</div>
<div data-flip-key="3">D</div>
</div>
</div>
</body>
<script src="./dist/flipping.web.js"></script>
<script src="./node_modules/gsap/src/minified/TweenLite.min.js"></script>
<script src="./node_modules/gsap/src/minified/plugins/CSSPlugin.min.js"></script>
<script>
window.flipFoo = new Flipping({
// selector: () => document.querySelectorAll('.layer.active [data-flip-key]'),
active: (node) => node.matches('.layer.active [data-flip-key]'),
duration: 3000,
});
// window.flipFoo = new Flipping({
// selector: () => document.querySelectorAll('.layer.active [data-flip-key]'),
// onRead: (({ animation }) => {
// if (animation) {
// animation.progress(1).kill();
// }
// }),
// onFlip: ((state) => {
// const node = state.node;
// const from = {
// x: state.delta.left,
// y: state.delta.top,
// scaleX: state.delta.width,
// scaleY: state.delta.height,
// transformOrigin: 'top left',
// };
// return TweenLite.fromTo(node, 3, from, { x: 0, y: 0, scaleX: 1, scaleY: 1 });
// }),
// });
const boxes = document.querySelectorAll('[data-flip-key]');
boxes.forEach(box => {
box.addEventListener('click', flipFoo.wrap(() => {
box.classList.toggle('active');
}));
});
window.foo = flipFoo.wrap(() => {
const layers = document.querySelectorAll('.layer');
layers[0].classList.toggle('active');
layers[1].classList.toggle('active');
});
</script>
</html>