Skip to content

Commit 80aa268

Browse files
committed
make demo content expandable
1 parent 873ab94 commit 80aa268

File tree

4 files changed

+41
-8
lines changed

4 files changed

+41
-8
lines changed

demo/content.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {genFromOptions} from "../internal/gen";
2727
import {BlobOptions} from "../public/blobs";
2828
import {interpolateBetween, interpolateBetweenSmooth} from "../internal/animate/interpolate";
2929
import {divide} from "../internal/animate/prepare";
30-
import blobs from "../public/legacy";
3130

3231
const makePoly = (pointCount: number, radius: number, center: Coord): Point[] => {
3332
const angle = (2 * Math.PI) / pointCount;
@@ -132,6 +131,7 @@ addCanvas(2, (ctx, width, height, animate) => {
132131
const startPeriod = Math.E * 1000;
133132
const endPeriod = Math.PI * 1000;
134133

134+
// TODO animate handle length.
135135
animate((frameTime) => {
136136
const startPercentage = calcBouncePercentage(startPeriod, timingFunctions.ease, frameTime);
137137
const startAngle = split(startPercentage, -45, +45);

demo/example.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {CanvasKeyframe, canvasPath} from "../public/animate";
2+
import {colors} from "./internal/layout";
23

34
// TODO add click me prompt before clicked.
45

@@ -29,7 +30,7 @@ const ctx = canvas.getContext("2d")!;
2930
const animation = canvasPath();
3031
const renderFrame = () => {
3132
ctx.clearRect(0, 0, size, size);
32-
ctx.fillStyle = "#ccc";
33+
ctx.fillStyle = colors.highlight;
3334
ctx.fill(animation.renderFrame());
3435
requestAnimationFrame(renderFrame);
3536
};

demo/index.html

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,45 @@
2424
height: 6rem;
2525
}
2626

27-
header nav a {
27+
header nav a, .how-it-works {
2828
color: #aaa;
2929
display: inline-block;
3030
font-size: 0.7rem;
3131
font-weight: 700;
3232
padding: 0.5rem;
3333
text-decoration: none;
34+
text-transform: uppercase;
35+
}
36+
37+
main {
38+
align-items: center;
39+
display: flex;
40+
flex-direction: column;
41+
}
42+
43+
.example {
44+
padding: 2.5rem 2rem;
45+
}
46+
47+
.how-it-works {
48+
cursor: pointer;
49+
transform: rotate(-2deg) translateY(-1px);
3450
user-select: none;
3551
}
3652

53+
.how-it-works.hidden {
54+
display: none;
55+
}
56+
3757
.container {
3858
align-items: center;
3959
display: flex;
4060
flex-direction: column;
41-
margin: 0 0 20vh;
42-
padding: 0 1rem;
61+
padding: 0 1rem 20vh;
4362
}
4463

45-
.container .example {
46-
padding: 2.5rem 0 8rem;
64+
.container:not(.open) {
65+
display: none;
4766
}
4867

4968
.container .title {
@@ -117,8 +136,10 @@
117136
>
118137
</nav>
119138
</header>
120-
<main class="container">
139+
<main>
121140
<div class="example"></div>
141+
<div class="how-it-works">How it works</div>
142+
<div class="container"></div>
122143
</main>
123144
<script src="./example.ts"></script>
124145
<script src="./content.ts"></script>

demo/internal/layout.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ const cells: Cell[][] = [];
3232
const containerElement = document.querySelector(".container");
3333
if (!containerElement) throw "missing container";
3434

35+
const howItWorksElement = document.querySelector(".how-it-works");
36+
if (!howItWorksElement) throw "missing container";
37+
38+
const reveal = () => {
39+
containerElement.classList.add("open");
40+
howItWorksElement.classList.add("hidden");
41+
redraw();
42+
};
43+
howItWorksElement.addEventListener("click", reveal);
44+
if (document.location.hash) setTimeout(reveal);
45+
3546
export const sizes = (): {width: number; pt: number} => {
3647
const sectionStyle = window.getComputedStyle(
3748
(containerElement.lastChild as any) || document.body,

0 commit comments

Comments
 (0)