forked from tajulafreen/50Projects-HTML-CSS-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
32 lines (26 loc) · 828 Bytes
/
script.js
File metadata and controls
32 lines (26 loc) · 828 Bytes
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
/* eslint-disable no-use-before-define */
const container = document.querySelector('.container');
const text = document.querySelector('#text');
const TOTAL_TIME = 7500;
const BREATHE_TIME = (TOTAL_TIME / 5) * 2;
const HOLD_TIME = TOTAL_TIME / 7;
// Start the animation
const startBreathingAnimation = () => {
animateBreathing();
setInterval(animateBreathing, TOTAL_TIME);
};
const animateBreathing = () => {
text.textContent = 'Breathe In!';
container.classList.add('grow');
container.classList.remove('shrink');
setTimeout(() => {
text.textContent = 'Hold...';
setTimeout(() => {
text.textContent = 'Breathe Out!';
container.classList.add('shrink');
container.classList.remove('grow');
}, HOLD_TIME);
}, BREATHE_TIME);
};
// Initialize the animation
startBreathingAnimation();