Skip to content

Commit 67f9c21

Browse files
Merge pull request #113 from curiosdevcookie/final_project_branch
Modify bee anmiamtions to run only once and on different routes.
2 parents 06942d5 + 0c88d04 commit 67f9c21

6 files changed

Lines changed: 209 additions & 189 deletions

File tree

week_11__final-project/spelling_bee/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@ pip install -r requirements.txt
4141

4242
### Set up the database
4343

44-
To install the database, you need to run the following commands in your terminal:
44+
To install the database, you need to run the following command in your terminal:
4545

4646
```bash
4747
wget "https://dl.dropboxusercontent.com/s/ooctnlclt9bdmeu/dictionary.db" -O dictionary.db
4848
```
4949

5050
### Configuration
5151

52-
Set the variable `is_local` to `True`.
52+
In your `app.py` file, set the `is_local` variable to `True`:
5353

5454
```python
5555
is_local = True
5656
```
5757

58-
This is important for app to choose the correct path to the database.
58+
This is important for the app to choose the correct path to the database.
5959

6060
### Run the app
6161

week_11__final-project/spelling_bee/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
# Check if the application should run locally or in docker, to run locally set is_local to True:
10-
is_local = False
10+
is_local = True
1111

1212
# Set the environment variable based on the mode:
1313
if is_local:

week_11__final-project/spelling_bee/fly.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# fly.toml app configuration file generated for urban-spelling-bee on 2023-06-19T16:33:30+02:00
1+
# fly.toml app configuration file generated for urban-spelling-bee on 2023-06-19T21:06:31+02:00
22
#
33
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
44
#

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

Lines changed: 76 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ main {
9595
}
9696

9797
footer {
98-
margin-top: -0.5rem;
98+
margin-top: -1rem;
9999
}
100100

101101
main {
@@ -136,8 +136,14 @@ main {
136136
align-self: self-start;
137137
display: none;
138138
}
139-
}
140139

140+
#beeOne {
141+
position: absolute;
142+
top: 63%;
143+
left: 72%;
144+
animation: jiggle 1s infinite;
145+
}
146+
}
141147

142148
#comb {
143149
grid-area: comb;
@@ -186,18 +192,15 @@ h6 {
186192
margin: 0;
187193
}
188194

189-
190195
/* Bee */
191196

192197
#beeOne {
193-
width: calc(5rem + 10vw);
194198
position: absolute;
195-
top: -30%;
196-
right: -10%;
197-
animation: fly 13s, jiggle 1s infinite;
199+
top: 10%;
200+
right: 68%;
201+
animation: jiggle 1s infinite;
198202
}
199203

200-
201204
/* Comb */
202205

203206
#comb {
@@ -373,38 +376,6 @@ dialog {
373376

374377
/* Animations */
375378

376-
@keyframes fly {
377-
0% {
378-
top: 30%;
379-
right: -20%;
380-
}
381-
382-
20% {
383-
top: 20%;
384-
right: 5%;
385-
}
386-
387-
40% {
388-
top: 15%;
389-
right: 10%;
390-
}
391-
392-
60% {
393-
top: 30%;
394-
right: 35%;
395-
}
396-
397-
80% {
398-
top: 60%;
399-
right: 60%;
400-
}
401-
402-
100% {
403-
top: 30%;
404-
right: 100%;
405-
}
406-
}
407-
408379
@keyframes jiggle {
409380
0% {
410381
transform: rotate(0deg);
@@ -465,7 +436,6 @@ dialog {
465436
}
466437
}
467438

468-
469439
@keyframes fade-in-out {
470440
0% {
471441
opacity: 0;
@@ -477,3 +447,68 @@ dialog {
477447
opacity: 0;
478448
}
479449
}
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: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,16 @@ function deleteLetter() {
2424
input.value = input.value.slice(0, -1);
2525
}
2626

27-
window.onload = function () {
27+
window.addEventListener('DOMContentLoaded', function () {
2828

2929
showInstructionsDialog();
30+
31+
setupButton('buttonCopyOrShareResult', eitherCopyOrShareResult);
32+
33+
showPangramPoints();
34+
35+
animateBeeOncePerScreensize();
36+
3037
function showInstructionsDialog() {
3138
const dialog = document.getElementById('dialog-instructions');
3239
const closeButton = document.getElementById('close-dialog');
@@ -49,6 +56,7 @@ window.onload = function () {
4956
}
5057

5158

59+
5260
const scoreArea = document.getElementById('score-area');
5361
const score = scoreArea.innerText;
5462
const sectionResults = document.getElementById('results');
@@ -119,9 +127,8 @@ window.onload = function () {
119127
img.src = URL.createObjectURL(svgBlob);
120128

121129
}
122-
setupButton('buttonCopyOrShareResult', eitherCopyOrShareResult);
123-
124130

131+
// Show the pangram bonus points:
125132
function showPangramPoints() {
126133
const pElement = document.querySelector('dialog p');
127134
if (pElement && pElement.textContent.includes('🐝')) {
@@ -130,5 +137,26 @@ window.onload = function () {
130137
}
131138
}
132139

133-
showPangramPoints();
134-
}
140+
141+
// Show the bee animation only once per session:
142+
function animateBeeOncePerScreensize() {
143+
const bee = document.getElementById('beeOne');
144+
const beeInnerWrapper = document.getElementById('beeOneInnerWrapper');
145+
if (!sessionStorage.getItem('beeShown')) {
146+
if (window.innerWidth <= 768) {
147+
// Add class for smaller screens and set animation duration
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+
153+
} else {
154+
// Add class for larger screens and set animation duration
155+
bee.style.animation = 'fly-large-screens 13s, jiggle 1s infinite';
156+
bee.style.top = '10%';
157+
bee.style.right = '68%';
158+
}
159+
sessionStorage.setItem('beeShown', 'true');
160+
}
161+
}
162+
});

0 commit comments

Comments
 (0)