Skip to content

Commit 0c88d04

Browse files
author
Ariadne Engelbrecht
committed
Create different bee animations for smaller and larger screens.
1 parent 3ab5b28 commit 0c88d04

3 files changed

Lines changed: 176 additions & 173 deletions

File tree

week_11__final-project/spelling_bee/static/css/index.css

Lines changed: 70 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,14 @@ main {
137137
display: none;
138138
}
139139

140-
#beeOne {
141-
width: 2rem;
140+
#beeOne {
142141
position: absolute;
143-
top: 5%;
144-
right: 85%;
142+
top: 63%;
143+
left: 72%;
145144
animation: jiggle 1s infinite;
146145
}
147146
}
148147

149-
150148
#comb {
151149
grid-area: comb;
152150
}
@@ -194,81 +192,15 @@ h6 {
194192
margin: 0;
195193
}
196194

197-
198195
/* Bee */
199196

200197
#beeOne {
201-
width: 5rem;
202198
position: absolute;
203-
top: 5%;
204-
right: 85%;
199+
top: 10%;
200+
right: 68%;
205201
animation: jiggle 1s infinite;
206202
}
207203

208-
@keyframes fly-small-screens {
209-
0% {
210-
top: 30%;
211-
right: -20%;
212-
}
213-
214-
20% {
215-
top: 20%;
216-
right: 5%;
217-
}
218-
219-
40% {
220-
top: 15%;
221-
right: 10%;
222-
}
223-
224-
60% {
225-
top: 30%;
226-
right: 35%;
227-
}
228-
229-
80% {
230-
top: 60%;
231-
right: 60%;
232-
}
233-
234-
100% {
235-
top: 5%;
236-
right: 85%;
237-
}
238-
}
239-
240-
@keyframes fly-large-screens {
241-
0% {
242-
top: 30%;
243-
right: -20%;
244-
}
245-
246-
20% {
247-
top: 20%;
248-
right: 5%;
249-
}
250-
251-
40% {
252-
top: 15%;
253-
right: 10%;
254-
}
255-
256-
60% {
257-
top: 30%;
258-
right: 35%;
259-
}
260-
261-
80% {
262-
top: 60%;
263-
right: 60%;
264-
}
265-
266-
100% {
267-
top: 5%;
268-
right: 85%;
269-
}
270-
}
271-
272204
/* Comb */
273205

274206
#comb {
@@ -444,8 +376,6 @@ dialog {
444376

445377
/* Animations */
446378

447-
448-
449379
@keyframes jiggle {
450380
0% {
451381
transform: rotate(0deg);
@@ -506,7 +436,6 @@ dialog {
506436
}
507437
}
508438

509-
510439
@keyframes fade-in-out {
511440
0% {
512441
opacity: 0;
@@ -518,3 +447,68 @@ dialog {
518447
opacity: 0;
519448
}
520449
}
450+
451+
@keyframes fly-small-screens {
452+
0% {
453+
top: 30%;
454+
left: -20%;
455+
}
456+
457+
20% {
458+
top: 20%;
459+
left: 5%;
460+
}
461+
462+
40% {
463+
top: 30%;
464+
left: 10%;
465+
}
466+
467+
60% {
468+
top: 60%;
469+
left: 35%;
470+
}
471+
472+
80% {
473+
top: 70%;
474+
left: 50%;
475+
}
476+
477+
100% {
478+
top: 10%;
479+
left: 72%;
480+
}
481+
}
482+
483+
484+
@keyframes fly-large-screens {
485+
0% {
486+
top: 30%;
487+
right: -20%;
488+
}
489+
490+
20% {
491+
top: 20%;
492+
right: 5%;
493+
}
494+
495+
40% {
496+
top: 30%;
497+
right: 10%;
498+
}
499+
500+
60% {
501+
top: 50%;
502+
right: 35%;
503+
}
504+
505+
80% {
506+
top: 60%;
507+
right: 60%;
508+
}
509+
510+
100% {
511+
top: 10%;
512+
right: 68%;
513+
}
514+
}

week_11__final-project/spelling_bee/static/js/index.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ window.addEventListener('DOMContentLoaded', function () {
3232

3333
showPangramPoints();
3434

35-
showBeeOnce();
35+
animateBeeOncePerScreensize();
3636

3737
function showInstructionsDialog() {
3838
const dialog = document.getElementById('dialog-instructions');
@@ -139,15 +139,22 @@ window.addEventListener('DOMContentLoaded', function () {
139139

140140

141141
// Show the bee animation only once per session:
142-
function showBeeOnce() {
142+
function animateBeeOncePerScreensize() {
143143
const bee = document.getElementById('beeOne');
144+
const beeInnerWrapper = document.getElementById('beeOneInnerWrapper');
144145
if (!sessionStorage.getItem('beeShown')) {
145146
if (window.innerWidth <= 768) {
146147
// Add class for smaller screens and set animation duration
147-
bee.style.animation = 'fly-small-screens 13s';
148+
bee.style.animation = 'fly-small-screens 3s, jiggle 1s infinite';
149+
bee.style.top = '10%';
150+
bee.style.left = '72%';
151+
beeInnerWrapper.setAttribute('transform', 'rotate(90 50 50)');
152+
148153
} else {
149154
// Add class for larger screens and set animation duration
150-
bee.style.animation = 'fly-large-screens 13s';
155+
bee.style.animation = 'fly-large-screens 13s, jiggle 1s infinite';
156+
bee.style.top = '10%';
157+
bee.style.right = '68%';
151158
}
152159
sessionStorage.setItem('beeShown', 'true');
153160
}

0 commit comments

Comments
 (0)