Skip to content

Commit dbd1fca

Browse files
committed
only animate explainer after opened
1 parent 27a01ee commit dbd1fca

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

demo/content.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const calcFullDetails = (percentage: number, a: Point, b: Point) => {
6565
return {a0, a1, a2, a3, b0, b1, b2, c0, c1, d0};
6666
};
6767

68-
addTitle(4, "What are vector graphics?");
68+
addTitle(4, "Vector graphics");
6969

7070
addCanvas(
7171
1.3,
@@ -211,7 +211,7 @@ addCanvas(2, (ctx, width, height, animate) => {
211211
approximated instead.`;
212212
});
213213

214-
addTitle(4, "How are blobs made?");
214+
addTitle(4, "Making a blob");
215215

216216
addCanvas(
217217
1.3,
@@ -362,7 +362,7 @@ addCanvas(
362362
},
363363
);
364364

365-
addTitle(4, "How are animated blobs interpolated?");
365+
addTitle(4, "Interpolating between blobs");
366366

367367
addCanvas(2, (ctx, width, height, animate) => {
368368
const period = Math.PI * 1000;

demo/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
flex-direction: column;
2020
align-items: center;
2121
padding: 2rem 0;
22+
user-select: none;
23+
-moz-user-select: none;
2224
}
2325

2426
header img {
@@ -34,8 +36,6 @@
3436
padding: 0.5rem;
3537
text-decoration: none;
3638
text-transform: uppercase;
37-
user-select: none;
38-
-moz-user-select: none;
3939
}
4040

4141
main {

demo/internal/layout.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ if (!containerElement) throw "missing container";
3838
const howItWorksElement = document.querySelector(".how-it-works");
3939
if (!howItWorksElement) throw "missing container";
4040

41+
let animating = false;
4142
const reveal = () => {
4243
containerElement.classList.add("open");
4344
howItWorksElement.classList.add("hidden");
45+
animating = true;
4446
redraw();
4547
};
4648
howItWorksElement.addEventListener("click", reveal);
@@ -147,6 +149,8 @@ const redraw = () => {
147149

148150
// Cell-specific callback for providing an animation painter.
149151
const animate = (painter: AnimationPainter) => {
152+
if (!animating) return;
153+
150154
const animationID = Math.random();
151155
const startTime = Date.now();
152156
cell.animationID = animationID;

0 commit comments

Comments
 (0)