-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
254 lines (234 loc) Β· 8.44 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<html lang="en" style="background-color: #fff">
<head>
<meta charset="utf-8" />
<title>Fish race</title>
<meta name="description" content="Fish race" />
<meta
name="viewport"
content="width=device-width, height=device-height, initial-scale=1"
/>
<link rel="icon" type="image/png" href="./favicon.svg" />
<style>
.flags-container {
width: 100%;
display: flex;
justify-content: flex-end;
margin-top: 2%;
margin-bottom: 2%;
}
#water {
position: relative;
clip-path: inset(-100vw -100vw -100vw 0);
max-width: 100%;
max-height: 100%;
}
#water-img {
aspect-ratio: 889/500;
max-width: 100%;
}
.image {
background-repeat: no-repeat, repeat;
}
main {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
height: 100%;
}
#race-container {
position: relative;
display: flex;
flex-direction: row-reverse;
margin-right: 4%;
margin-left: 1%;
}
#finish-img {
aspect-ratio: 25/500;
max-width: 100%;
}
.flags {
width: 12%;
aspect-ratio: 103/66;
}
#start-button {
display: none;
}
.counter {
display: none;
}
/* The fish class is critical CSS, because otherwise the fish are positioned elements and shift the layout when they are loaded. */
.fish {
display: inline-block;
position: absolute;
/* How the transition left and the time to move work together is magic to me right now
* TODO: figure out how those 2 properties relate
*/
transition: transform 0.05s;
width: 20%;
top: 0;
left: 0;
will-change: transform;
opacity: 0;
}
</style>
<script
async
src="https://www.googletagmanager.com/gtag/js?id=UA-175557590-1"
></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "UA-175557590-1");
</script>
</head>
<body style="margin: 0">
<main>
<div id="content-container">
<div class="flags-container">
<img class="image flags" src="./assets/flags.png" />
</div>
<div id="race-container">
<div id="finish">
<img
id="finish-img"
class="image"
src="assets/finish_line/finish.png"
/>
</div>
<div id="water" class="image">
<img id="water-img" src="./assets/water/frame_1.png" width="889" />
<span id="fish1" class="fish">
<img id="image-fish1" src="./assets/fish1/frame_1.png" />
<img id="crown-fish1" class="crown" src="./assets/crown.png" />
</span>
<span id="fish2" class="fish">
<img id="image-fish2" src="./assets/fish2/frame_1.png" />
<img id="crown-fish2" class="crown" src="./assets/crown.png" />
</span>
<span id="fish3" class="fish">
<img id="image-fish3" src="./assets/fish3/frame_1.png" />
<img id="crown-fish3" class="crown" src="./assets/crown.png" />
</span>
<span id="fish4" class="fish">
<img id="image-fish4" src="./assets/fish4/frame_1.png" />
<img id="crown-fish4" class="crown" src="./assets/crown.png" />
</span>
<img
id="restart"
style="
position: absolute;
opacity: 0;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
cursor: pointer;
visibility: hidden;
width: 26%;
z-index: 3;
"
src="./assets/restartbutton/restart.svg"
width="190"
height="190"
/>
</div>
<div id="count-container">
<img
id="count-element3"
class="counter"
src="assets/counters/three.png"
/>
<img
id="count-element2"
class="counter"
src="assets/counters/two.png"
/>
<img
id="count-element1"
class="counter"
src="assets/counters/one.png"
/>
<img id="count-go" class="counter" src="assets/counters/go.png" />
</div>
</div>
<div class="flags-container">
<img class="image flags" src="./assets/flags.png" />
</div>
</div>
</main>
<script defer src="src/core.js" onload="core();"></script>
<link defer rel="stylesheet" type="text/css" href="src/core.css" />
<script>
/*
MIT License
Copyright (c) 2019 Jacob Filipp
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
// Add this script into the page that will appear <b>inside an iFrame</b>
// This code monitors the page for changes in size. When change is detected, it sends send the latest size to the parent page using postMessage
// determine height of content on this page
const contentContainer = document.getElementById("content-container");
function getMyHeight() {
return contentContainer.scrollHeight;
}
// send the latest page dimensions to the parent page on which this iframe is embedded
function sendDimensionsToParent() {
var iframeDimensions_New = {
width: window.innerWidth, //supported from IE9 onwards
height: getMyHeight(),
};
if (
iframeDimensions_New.width != iframeDimensions_Old.width ||
iframeDimensions_New.height != iframeDimensions_Old.height
) {
// if old width is not equal new width, or old height is not equal new height, then...
window.parent.postMessage(iframeDimensions_New, "*");
iframeDimensions_Old = iframeDimensions_New;
}
}
// on load - send the page dimensions. (we do this on load because then all images have loaded...)
window.addEventListener("load", function () {
iframeDimensions_Old = {
width: window.innerWidth, //supported from IE9 onwards
height: getMyHeight(),
};
window.parent.postMessage(iframeDimensions_Old, "*"); //send our dimensions once, initially - so the iFrame is initialized to the correct size
if (window.MutationObserver) {
// if mutationobserver is supported by this browser
//https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
var observer = new MutationObserver(sendDimensionsToParent);
config = {
attributes: true,
attributeOldValue: false,
characterData: true,
characterDataOldValue: false,
childList: true,
subtree: true,
};
observer.observe(document.body, config);
} // if mutationobserver is NOT supported
else {
//check for changes on a timed interval, every 1/3 of a second
window.setInterval(sendDimensionsToParent, 300);
}
}); // end of window.onload
</script>
</body>
</html>