Skip to content

Commit 3090a84

Browse files
committed
add page, work towards unifying
1 parent 49c4f97 commit 3090a84

3 files changed

Lines changed: 570 additions & 0 deletions

File tree

animations.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Animation system for math problems
2+
class AnimationSystem {
3+
constructor() {
4+
this.starsContainer = document.getElementById('stars-container');
5+
}
6+
7+
// Create a star element with random properties
8+
createStar() {
9+
const star = document.createElement('div');
10+
star.className = 'star';
11+
star.textContent = '⭐';
12+
star.style.left = Math.random() * window.innerWidth + 'px';
13+
star.style.fontSize = `${Math.random() * 20 + 20}px`; // Random size between 20-40px
14+
star.style.animationDuration = `${Math.random() * 1.5 + 0.5}s`; // Random duration between 0.5-2s
15+
return star;
16+
}
17+
18+
// Handle correct answer animation
19+
handleCorrectAnswer(selectedOption, allOptions, callback) {
20+
// Disable all options
21+
Array.from(allOptions).forEach(option => {
22+
option.disabled = true;
23+
option.onclick = null;
24+
});
25+
26+
// Add correct class to the selected option
27+
selectedOption.classList.add('correct');
28+
29+
// Create and animate stars
30+
const numStars = 10; // Consistent number of stars for all problems
31+
for (let i = 0; i < numStars; i++) {
32+
const star = this.createStar();
33+
this.starsContainer.appendChild(star);
34+
setTimeout(() => {
35+
star.remove();
36+
}, 2000);
37+
}
38+
39+
// Wait for animation to complete before moving to next problem
40+
setTimeout(callback, 1000);
41+
}
42+
43+
// Handle wrong answer animation
44+
handleWrongAnswer(option) {
45+
option.classList.add('wrong');
46+
setTimeout(() => option.classList.remove('wrong'), 500);
47+
}
48+
}
49+
50+
// Export a single instance to be used across all problems
51+
const animationSystem = new AnimationSystem();

metric-units-length.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Appropriate Metric Unit of Length</title>
7+
<link rel="stylesheet" href="styles.css">
8+
</head>
9+
<body>
10+
<div class="main-content">
11+
<div class="problem-area">
12+
<div class="header-container">
13+
<a href="index.html" class="home-button">🏠 Home</a>
14+
<h1>Fun Math Problems! 🎨</h1>
15+
<button class="toggle-scratchpad" id="toggle-scratchpad">📝 Open Scratchpad</button>
16+
</div>
17+
<div class="container">
18+
<div class="problem" id="problem-text"></div>
19+
<div class="options" id="options-container">
20+
<button class="option"></button>
21+
<button class="option"></button>
22+
</div>
23+
<div class="navigation">
24+
<button class="nav-button" id="prev-btn">← Previous</button>
25+
<button class="nav-button" id="next-btn">Next →</button>
26+
</div>
27+
</div>
28+
</div>
29+
<div class="scratchpad-area" id="scratchpad-area">
30+
<div class="scratchpad-controls">
31+
<button class="scratchpad-button" id="undo-btn">↩️ Undo</button>
32+
<button class="scratchpad-button" id="redo-btn">↪️ Redo</button>
33+
<button class="scratchpad-button clear" id="clear-btn">🗑️ Clear</button>
34+
<button class="scratchpad-button" id="close-scratchpad">❌ Close</button>
35+
</div>
36+
<canvas class="scratchpad-canvas" id="scratchpad"></canvas>
37+
</div>
38+
</div>
39+
<div class="problem-type">
40+
Appropriate Metric Unit of Length
41+
</div>
42+
<div class="stars" id="stars-container"></div>
43+
<script src="animations.js"></script>
44+
<script src="metric-units-length.js"></script>
45+
</body>
46+
</html>

0 commit comments

Comments
 (0)