@openbooknetwork/hesap 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +112 -2
- package/package.json +45 -4
- package/scripts/assemble.mjs +40 -0
- package/src/client.css +186 -0
- package/src/client.js +111 -0
- package/src/families/counters/bonds.js +414 -0
- package/src/families/counters/client.css +96 -0
- package/src/families/counters/client.js +21 -0
- package/src/families/counters/counter.js +32 -0
- package/src/families/counters/driver.js +16 -0
- package/src/families/counters/figures.js +172 -0
- package/src/families/counters/frame.js +28 -0
- package/src/families/counters/goals.js +75 -0
- package/src/families/counters/i18n/en.yaml +52 -0
- package/src/families/counters/i18n/tr.yaml +52 -0
- package/src/families/counters/index.mjs +103 -0
- package/src/families/counters/model.js +86 -0
- package/src/families/counters/move.js +42 -0
- package/src/families/counters/places.js +45 -0
- package/src/families.mjs +5 -0
- package/src/i18n/en.yaml +67 -0
- package/src/i18n/tr.yaml +67 -0
- package/src/index.mjs +82 -0
- package/src/kit/dom.js +32 -0
- package/src/kit/drag.js +40 -0
- package/src/kit/format.js +34 -0
- package/src/kit/goal.js +49 -0
- package/src/kit/i18n/en.yaml +15 -0
- package/src/kit/i18n/tr.yaml +15 -0
- package/src/kit/kit.css +89 -0
- package/src/kit/motion.js +44 -0
- package/src/kit/panel.js +70 -0
- package/src/kit/play.js +26 -0
- package/src/kit/random.js +35 -0
- package/src/kit/text.js +25 -0
- package/src/node.mjs +43 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Where counters sit inside a place, and how the blocks of a figure are set out on the stage.
|
|
2
|
+
|
|
3
|
+
// cluster sets n counters in short centred rows round the point 0, 0, so a part reads at a glance.
|
|
4
|
+
export function cluster(n, gap) {
|
|
5
|
+
const cols = n <= 3 ? n : n === 4 ? 2 : n <= 9 ? 3 : n <= 16 ? 4 : 5, rows = Math.ceil(n / cols);
|
|
6
|
+
return Array.from({ length: n }, (_, i) => {
|
|
7
|
+
const r = Math.floor(i / cols), inRow = r === rows - 1 ? n - r * cols : cols, c = i % cols;
|
|
8
|
+
return { x: (c - (inRow - 1) / 2) * gap, y: (r - (rows - 1) / 2) * gap };
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
// reach gives how far from the middle the counters of a cluster of up to max counters go.
|
|
12
|
+
export const reach = (max, gap) => Math.max(0, ...Array.from({ length: max }, (_, n) => Math.max(...cluster(n + 1, gap).map(p => Math.hypot(p.x, p.y)))));
|
|
13
|
+
|
|
14
|
+
// grid sets counters in rows of cols from the top left, the way a tray holds them.
|
|
15
|
+
export const grid = (i, cols, gap) => ({ x: (i % cols + 0.5) * gap, y: (Math.floor(i / cols) + 0.5) * gap });
|
|
16
|
+
|
|
17
|
+
// heap sets counters in a pile that narrows to the top, with these rows from the bottom.
|
|
18
|
+
export const HEAP = [5, 5, 4, 3, 2, 1];
|
|
19
|
+
export function heap(i, gap) {
|
|
20
|
+
let row = 0, left = i;
|
|
21
|
+
while (row < HEAP.length - 1 && left >= HEAP[row]) { left -= HEAP[row]; row++; }
|
|
22
|
+
const n = HEAP[row] ?? 1, shift = row % 2 && n === HEAP[row - 1] ? 0.5 : 0;
|
|
23
|
+
return { x: (left - (n - 1) / 2 + shift) * gap * 0.86, y: -row * gap * 0.64 };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// The gap between two blocks of a figure.
|
|
27
|
+
const SPACE = 28;
|
|
28
|
+
// arrange tries each way to set out the blocks, one under another, side by side, or the last block beside the
|
|
29
|
+
// others, with each block's own ways, and keeps the one that fits the box w by h at the largest scale.
|
|
30
|
+
export function arrange(blocks, w, h) {
|
|
31
|
+
const combos = blocks.reduce((all, ways) => all.flatMap(c => ways.map(v => [...c, v])), [[]]);
|
|
32
|
+
let best = null;
|
|
33
|
+
const offer = (cw, ch, items) => { const scale = Math.min(w / cw, h / ch); if (!best || scale > best.scale + 1e-6) best = { scale, w: cw, h: ch, items }; };
|
|
34
|
+
const column = vs => { const cw = Math.max(...vs.map(v => v.w)); let y = 0; return { w: cw, h: vs.reduce((s, v) => s + v.h, 0) + SPACE * (vs.length - 1), items: vs.map(v => { const it = { v, x: (cw - v.w) / 2, y }; y += v.h + SPACE; return it; }) }; };
|
|
35
|
+
for (const vs of combos) {
|
|
36
|
+
const col = column(vs); offer(col.w, col.h, col.items);
|
|
37
|
+
if (vs.length < 2) continue;
|
|
38
|
+
const rh = Math.max(...vs.map(v => v.h)); let x = 0;
|
|
39
|
+
offer(vs.reduce((s, v) => s + v.w, 0) + SPACE * (vs.length - 1), rh, vs.map(v => { const it = { v, x, y: (rh - v.h) / 2 }; x += v.w + SPACE; return it; }));
|
|
40
|
+
if (vs.length < 3) continue;
|
|
41
|
+
const main = column(vs.slice(0, -1)), side = vs.at(-1), sh = Math.max(main.h, side.h);
|
|
42
|
+
offer(main.w + SPACE + side.w, sh, [...main.items.map(it => ({ ...it, y: it.y + (sh - main.h) / 2 })), { v: side, x: main.w + SPACE, y: (sh - side.h) / 2 }]);
|
|
43
|
+
}
|
|
44
|
+
return best;
|
|
45
|
+
}
|
package/src/families.mjs
ADDED
package/src/i18n/en.yaml
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
hint: Move the figure and watch the numbers follow it.
|
|
2
|
+
tab_map: Figure
|
|
3
|
+
map_data: Data
|
|
4
|
+
map_view: View
|
|
5
|
+
chronology: Contents
|
|
6
|
+
layout_center: Figure in the middle
|
|
7
|
+
view_reset: Reset
|
|
8
|
+
hesap_start: Start
|
|
9
|
+
hesap_time: Time
|
|
10
|
+
hesap_reset: Start again
|
|
11
|
+
hesap_undo: Undo
|
|
12
|
+
hesap_hint: Hint
|
|
13
|
+
hesap_another: Another one
|
|
14
|
+
hesap_solved: Solved
|
|
15
|
+
hesap_not-yet: Not solved yet.
|
|
16
|
+
counters_lead: "Drag the counters, tap the cells and watch the two parts make the whole."
|
|
17
|
+
counters_whole: Whole
|
|
18
|
+
counters_first: First part
|
|
19
|
+
counters_second: Second part
|
|
20
|
+
counters_empty: Empty cells
|
|
21
|
+
counters_added: Blue added
|
|
22
|
+
counters_found: Splits found
|
|
23
|
+
counters_ways: Splits in all
|
|
24
|
+
counters_hands-first: Left hand
|
|
25
|
+
counters_hands-second: Right hand
|
|
26
|
+
counters_hands-whole: Beads
|
|
27
|
+
counters_one-first: Counters
|
|
28
|
+
counters_one-found: Pairs found
|
|
29
|
+
counters_one-ways: Pairs in all
|
|
30
|
+
counters_two-first: Red
|
|
31
|
+
counters_two-second: Blue
|
|
32
|
+
counters_cup-first: Part in sight
|
|
33
|
+
counters_cup-second: Hidden part
|
|
34
|
+
counters_cup-added: Blue added
|
|
35
|
+
counters_pins-first: Standing
|
|
36
|
+
counters_pins-empty: Knocked down
|
|
37
|
+
counters_cars-first: Parked
|
|
38
|
+
counters_cars-empty: Free spaces
|
|
39
|
+
counters_ctl-whole: Whole
|
|
40
|
+
counters_swap: Swap
|
|
41
|
+
counters_fill: Fill the second frame
|
|
42
|
+
counters_unfill: Empty the second frame
|
|
43
|
+
counters_lift: Lift the cup
|
|
44
|
+
counters_lower: Put the cup back
|
|
45
|
+
counters_check: Check
|
|
46
|
+
counters_blue: Blue counters
|
|
47
|
+
counters_tray: Tray
|
|
48
|
+
counters_pile: Pile
|
|
49
|
+
counters_cup: Cup
|
|
50
|
+
counters_counter: Counter
|
|
51
|
+
counters_car: Car
|
|
52
|
+
counters_cell: "Cell {x}"
|
|
53
|
+
counters_pin-up: "Pin {x}, standing"
|
|
54
|
+
counters_pin-down: "Pin {x}, knocked down"
|
|
55
|
+
counters_free: Free
|
|
56
|
+
counters_pair: "{a} and {b}"
|
|
57
|
+
counters_list-splits: "Splits of {x}"
|
|
58
|
+
counters_list-pairs: "Pairs that make {x}"
|
|
59
|
+
counters_goal-make-whole: "The red tray holds {part}. Set the blue counters so that the frame holds {whole}, then press Check."
|
|
60
|
+
counters_goal-make-whole-two: "The red tray holds {part}. Set the blue counters so that the two frames hold {whole}, then press Check."
|
|
61
|
+
counters_goal-hidden-part: "The whole is {whole}, and the part in sight is {part}. Build the part under the cup in the tray, then lift the cup."
|
|
62
|
+
counters_note-short: Some cells are still empty.
|
|
63
|
+
counters_note-over: Some counters found no cell.
|
|
64
|
+
counters_note-more: The tray holds more counters than the cup.
|
|
65
|
+
counters_note-fewer: The tray holds fewer counters than the cup.
|
|
66
|
+
counters_hint-make-whole: "Count on from {part} to {whole}. Each number you say after {part} is one blue counter."
|
|
67
|
+
counters_hint-hidden-part: "Count on from {part} to {whole}. Each number you say after {part} is one counter under the cup."
|
package/src/i18n/tr.yaml
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
hint: Şekli hareket ettirin ve sayıların onu izleyişine bakın.
|
|
2
|
+
tab_map: Şekil
|
|
3
|
+
map_data: Veri
|
|
4
|
+
map_view: Görünüm
|
|
5
|
+
chronology: İçindekiler
|
|
6
|
+
layout_center: Şekil ortada
|
|
7
|
+
view_reset: Sıfırla
|
|
8
|
+
hesap_start: Başlat
|
|
9
|
+
hesap_time: Zaman
|
|
10
|
+
hesap_reset: Baştan başla
|
|
11
|
+
hesap_undo: Geri al
|
|
12
|
+
hesap_hint: İpucu
|
|
13
|
+
hesap_another: Bir tane daha
|
|
14
|
+
hesap_solved: Çözüldü
|
|
15
|
+
hesap_not-yet: Henüz çözülmedi.
|
|
16
|
+
counters_lead: "Sayaçları sürükleyin, hücrelere dokunun ve iki parçanın bütünü nasıl oluşturduğunu izleyin."
|
|
17
|
+
counters_whole: Bütün
|
|
18
|
+
counters_first: Birinci parça
|
|
19
|
+
counters_second: İkinci parça
|
|
20
|
+
counters_empty: Boş hücreler
|
|
21
|
+
counters_added: Eklenen mavi
|
|
22
|
+
counters_found: Bulunan ayrımlar
|
|
23
|
+
counters_ways: Tüm ayrımlar
|
|
24
|
+
counters_hands-first: Sol el
|
|
25
|
+
counters_hands-second: Sağ el
|
|
26
|
+
counters_hands-whole: Boncuklar
|
|
27
|
+
counters_one-first: Sayaçlar
|
|
28
|
+
counters_one-found: Bulunan ikililer
|
|
29
|
+
counters_one-ways: Tüm ikililer
|
|
30
|
+
counters_two-first: Kırmızı
|
|
31
|
+
counters_two-second: Mavi
|
|
32
|
+
counters_cup-first: Görünen parça
|
|
33
|
+
counters_cup-second: Gizli parça
|
|
34
|
+
counters_cup-added: Eklenen mavi
|
|
35
|
+
counters_pins-first: Ayakta
|
|
36
|
+
counters_pins-empty: Devrilen
|
|
37
|
+
counters_cars-first: Park eden
|
|
38
|
+
counters_cars-empty: Boş yerler
|
|
39
|
+
counters_ctl-whole: Bütün
|
|
40
|
+
counters_swap: Yer değiştir
|
|
41
|
+
counters_fill: İkinci çerçeveyi doldur
|
|
42
|
+
counters_unfill: İkinci çerçeveyi boşalt
|
|
43
|
+
counters_lift: Bardağı kaldır
|
|
44
|
+
counters_lower: Bardağı geri koy
|
|
45
|
+
counters_check: Kontrol et
|
|
46
|
+
counters_blue: Mavi sayaçlar
|
|
47
|
+
counters_tray: Tepsi
|
|
48
|
+
counters_pile: Yığın
|
|
49
|
+
counters_cup: Bardak
|
|
50
|
+
counters_counter: Sayaç
|
|
51
|
+
counters_car: Araba
|
|
52
|
+
counters_cell: "Hücre {x}"
|
|
53
|
+
counters_pin-up: "Lobut {x}, ayakta"
|
|
54
|
+
counters_pin-down: "Lobut {x}, devrik"
|
|
55
|
+
counters_free: Boş
|
|
56
|
+
counters_pair: "{a} ve {b}"
|
|
57
|
+
counters_list-splits: "{x} sayısının ayrımları"
|
|
58
|
+
counters_list-pairs: "{x} yapan ikililer"
|
|
59
|
+
counters_goal-make-whole: "Kırmızı tepside {part} sayaç var. Çerçeve {whole} sayaç tutacak biçimde mavi sayaçları ayarlayın, sonra Kontrol et düğmesine basın."
|
|
60
|
+
counters_goal-make-whole-two: "Kırmızı tepside {part} sayaç var. İki çerçeve {whole} sayaç tutacak biçimde mavi sayaçları ayarlayın, sonra Kontrol et düğmesine basın."
|
|
61
|
+
counters_goal-hidden-part: "Bütün {whole}, görünen parça {part}. Bardağın altındaki parçayı tepside kurun, sonra bardağı kaldırın."
|
|
62
|
+
counters_note-short: Bazı hücreler hâlâ boş.
|
|
63
|
+
counters_note-over: Bazı sayaçlara hücre kalmadı.
|
|
64
|
+
counters_note-more: Tepside bardaktakinden çok sayaç var.
|
|
65
|
+
counters_note-fewer: Tepside bardaktakinden az sayaç var.
|
|
66
|
+
counters_hint-make-whole: "{part} sayısından {whole} sayısına kadar ileri sayın. {part} sayısından sonra söylediğiniz her sayı bir mavi sayaçtır."
|
|
67
|
+
counters_hint-hidden-part: "{part} sayısından {whole} sayısına kadar ileri sayın. {part} sayısından sonra söylediğiniz her sayı bardağın altındaki bir sayaçtır."
|
package/src/index.mjs
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Hesap's Node half, the engine module kitap loads. A page names a scene under the hesap key, and the family that
|
|
2
|
+
// owns the scene reads the rest of the page's fields, checks them and says what each link in the text shows when
|
|
3
|
+
// the page opens.
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { schema } from '@openbooknetwork/kitap';
|
|
7
|
+
import FAMILIES from './families.mjs';
|
|
8
|
+
import { LINK, list, links } from './node.mjs';
|
|
9
|
+
|
|
10
|
+
const { z, check } = schema;
|
|
11
|
+
const PKG = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
12
|
+
const family = id => FAMILIES.find(f => f.id === id);
|
|
13
|
+
// A page names a scene as <family>/<scene>, such as counters/bonds. A family whose one scene has the family's name is
|
|
14
|
+
// named alone.
|
|
15
|
+
const nameOf = (fam, scene) => scene === fam.id ? scene : `${fam.id}/${scene}`;
|
|
16
|
+
const SCENES = FAMILIES.flatMap(f => f.scenes.map(s => nameOf(f, s)));
|
|
17
|
+
function owner(name) {
|
|
18
|
+
const [id, scene, more] = name.split('/'), fam = family(id), own = scene ?? id;
|
|
19
|
+
return fam && more === undefined && fam.scenes.includes(own) ? { fam, scene: own } : null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const PageHesap = z.object({ scene: z.string() }).passthrough();
|
|
23
|
+
|
|
24
|
+
// has remembers which links each page holds, so finish checks only those.
|
|
25
|
+
const HAS = new Map(), keyOf = (ctx, pid) => `${ctx.where}/${pid}`;
|
|
26
|
+
|
|
27
|
+
function readPage(fields, info, ctx) {
|
|
28
|
+
const { scene: name, ...rest } = check(PageHesap, fields, info.at), own = owner(name);
|
|
29
|
+
if (!own) { ctx.fail(info.at, `scene is "${name}", the scenes are ${list(SCENES)}`); return { data: {} }; }
|
|
30
|
+
const { fam, scene } = own, r = fam.read({ scene, ...check(fam.schema, rest, info.at) }, info, ctx);
|
|
31
|
+
HAS.set(keyOf(ctx, info.pid), r.has);
|
|
32
|
+
return { data: { ...r.data, scene, family: fam.id }, links: links(r.has, r.offers) };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// A text types into each link what the page shows when it opens, and a text that differs is told what to write.
|
|
36
|
+
function finish({ pages, texts }, ctx) {
|
|
37
|
+
// A page whose page.yaml failed has no family, and its problem is printed already.
|
|
38
|
+
for (const pg of pages.filter(p => p.hesap?.family)) {
|
|
39
|
+
const fam = family(pg.hesap.family), has = HAS.get(keyOf(ctx, pg.id));
|
|
40
|
+
for (const [lang, text] of Object.entries(texts[pg.id] ?? {})) for (const [, name, id] of text.matchAll(LINK)) {
|
|
41
|
+
// Kitap reports a link the page does not hold, so the family is asked only about its own.
|
|
42
|
+
if (has && !has(id)) continue;
|
|
43
|
+
ctx.attempt(path.join(ctx.root, pg.dir), () => {
|
|
44
|
+
const want = fam.start(pg.hesap, lang, id);
|
|
45
|
+
if (want !== null && want !== undefined && name !== want) ctx.fail(`${pg.dir}/text/${lang}.md`, `[${name}](@${id}) differs from what the page shows at the start, write [${want}](@${id})`);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return {};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// A story's bundle holds the data and the colour families of the families its pages use. A story with no cover
|
|
53
|
+
// opens on the overview scene of its first page's family, or on its first page's figure.
|
|
54
|
+
function bundle(content) {
|
|
55
|
+
const data = {}, families = {}, from = {}, pages = (content.pages ?? []).filter(p => p.hesap?.family);
|
|
56
|
+
for (const id of new Set(pages.map(p => p.hesap.family))) {
|
|
57
|
+
const b = family(id).bundle?.(content) ?? {};
|
|
58
|
+
if (b.data) data[id] = b.data;
|
|
59
|
+
for (const [name, colour] of Object.entries(b.families ?? {})) {
|
|
60
|
+
if (from[name]) throw new Error(`hesap: the families ${from[name]} and ${id} both define the colour "${name}", rename one`);
|
|
61
|
+
from[name] = id; families[name] = colour;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const first = pages[0]?.hesap;
|
|
65
|
+
if (first) data.overview = data[first.family]?.overview ? { ...data[first.family].overview, family: first.family } : first;
|
|
66
|
+
return { data, families, credits: [] };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default {
|
|
70
|
+
id: 'hesap',
|
|
71
|
+
dir: PKG,
|
|
72
|
+
schemas: { page: PageHesap },
|
|
73
|
+
ui: new URL('./i18n/', import.meta.url),
|
|
74
|
+
// The browser imports hesap's own modules and KaTeX's stylesheet through kitap's import map, from folders named
|
|
75
|
+
// after each package's version. A family that draws with a library of its own adds it here, so the library
|
|
76
|
+
// loads with that family alone.
|
|
77
|
+
client: { script: new URL('./client.js', import.meta.url), styles: new URL('./client.css', import.meta.url), module: true,
|
|
78
|
+
libraries: [['animejs', 'dist/bundles/anime.umd.min.js'], ['katex', 'dist/katex.min.js']],
|
|
79
|
+
imports: { 'hesap/': ['@openbooknetwork/hesap', 'src'], 'katex-dist/': ['katex', 'dist'] } },
|
|
80
|
+
read: { page: readPage, finish },
|
|
81
|
+
bundle,
|
|
82
|
+
};
|
package/src/kit/dom.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Small helpers for building the page: SVG and HTML elements, escaping and the icons the panel uses.
|
|
2
|
+
const NS = 'http://www.w3.org/2000/svg';
|
|
3
|
+
export const esc = s => String(s ?? '').replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
4
|
+
// svg makes an SVG element with its attributes and children.
|
|
5
|
+
export function svg(tag, attrs = {}, kids = []) {
|
|
6
|
+
const n = document.createElementNS(NS, tag);
|
|
7
|
+
for (const [k, v] of Object.entries(attrs)) if (v !== undefined && v !== null) n.setAttribute(k, v);
|
|
8
|
+
n.append(...kids);
|
|
9
|
+
return n;
|
|
10
|
+
}
|
|
11
|
+
// h makes an HTML element. A text child is written as text, so it needs no escaping.
|
|
12
|
+
export function h(tag, attrs = {}, kids = []) {
|
|
13
|
+
const n = document.createElement(tag);
|
|
14
|
+
for (const [k, v] of Object.entries(attrs)) if (v !== undefined && v !== null && v !== false) n.setAttribute(k, v === true ? '' : v);
|
|
15
|
+
n.append(...[kids].flat());
|
|
16
|
+
return n;
|
|
17
|
+
}
|
|
18
|
+
const ICONS = {
|
|
19
|
+
reset: '<path d="M5.6 9.5A7 7 0 1 1 5 13.5" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"/><path d="M3.5 4.5v6.5h6.5z"/>',
|
|
20
|
+
tick: '<path d="M4.5 12.5l5 5 10-11" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"/>',
|
|
21
|
+
undo: '<path d="M9 7H15a5 5 0 0 1 0 10H8" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"/><path d="M10 2.5v9L4 7z"/>',
|
|
22
|
+
};
|
|
23
|
+
export function icon(id) {
|
|
24
|
+
const s = svg('svg', { viewBox: '0 0 24 24', 'aria-hidden': 'true', fill: 'currentColor', class: 'hesap-icon' });
|
|
25
|
+
s.innerHTML = ICONS[id];
|
|
26
|
+
return s;
|
|
27
|
+
}
|
|
28
|
+
// svgPoint gives a pointer event's place in the coordinates of an SVG element.
|
|
29
|
+
export function svgPoint(node, e) {
|
|
30
|
+
const p = new DOMPoint(e.clientX, e.clientY).matrixTransform(node.getScreenCTM().inverse());
|
|
31
|
+
return { x: p.x, y: p.y };
|
|
32
|
+
}
|
package/src/kit/drag.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Dragging with pointer events, the same by mouse and by touch.
|
|
2
|
+
// drag lets the reader drag node. point turns an event into the family's coordinates. start may return false to
|
|
3
|
+
// refuse the drag, and raise moves the node in the page before the pointer is captured, because moving an element
|
|
4
|
+
// releases its capture.
|
|
5
|
+
export function drag(node, { point, start, move, drop, raise }) {
|
|
6
|
+
let held = null;
|
|
7
|
+
// drop gets the event that ended the drag, so a family can tell a release from a cancel.
|
|
8
|
+
const end = e => { if (held === null) return; held = null; node.classList.remove('drag'); drop?.(e); };
|
|
9
|
+
node.addEventListener('pointerdown', e => {
|
|
10
|
+
if (e.button) return;
|
|
11
|
+
const p = point(e);
|
|
12
|
+
if (start?.(p, e) === false) return;
|
|
13
|
+
e.preventDefault(); e.stopPropagation();
|
|
14
|
+
raise?.();
|
|
15
|
+
try { node.setPointerCapture(e.pointerId); } catch {} // A pointer that a script made has nothing to capture.
|
|
16
|
+
held = e.pointerId; node.classList.add('drag');
|
|
17
|
+
});
|
|
18
|
+
node.addEventListener('pointermove', e => {
|
|
19
|
+
if (held !== e.pointerId) return;
|
|
20
|
+
if (e.pointerType === 'mouse' && !e.buttons) return end(e); // The button came up where the page could not see it.
|
|
21
|
+
move(point(e), e);
|
|
22
|
+
});
|
|
23
|
+
for (const ev of ['pointerup', 'pointercancel', 'lostpointercapture']) node.addEventListener(ev, end);
|
|
24
|
+
return { held: () => held !== null, end };
|
|
25
|
+
}
|
|
26
|
+
const ARROWS = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] };
|
|
27
|
+
// nudge moves a focused node with the arrow keys. The keys stop at the node, because the book turns the page on
|
|
28
|
+
// Left and Right. rest runs once the keys go quiet.
|
|
29
|
+
export function nudge(node, { step, rest, idle = 800 }) {
|
|
30
|
+
let timer = 0;
|
|
31
|
+
node.addEventListener('keydown', e => {
|
|
32
|
+
const d = ARROWS[e.key];
|
|
33
|
+
if (!d) return;
|
|
34
|
+
e.preventDefault(); e.stopPropagation();
|
|
35
|
+
step(d[0], d[1], e);
|
|
36
|
+
if (rest) { clearTimeout(timer); timer = setTimeout(rest, idle); }
|
|
37
|
+
});
|
|
38
|
+
node.addEventListener('blur', () => { if (timer) { clearTimeout(timer); timer = 0; rest?.(); } });
|
|
39
|
+
return { cancel: () => { clearTimeout(timer); timer = 0; } };
|
|
40
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// How numbers and worked formulas are written in a language. The browser and the build both use it, so a page's
|
|
2
|
+
// text and its live values agree.
|
|
3
|
+
const MINUS = '−';
|
|
4
|
+
// fill puts values into a string's {name} places. A string with one {x} takes a plain value.
|
|
5
|
+
export function fill(s, vars) {
|
|
6
|
+
if (vars === undefined || vars === null || s === undefined) return s;
|
|
7
|
+
return typeof vars === 'object' ? s.replace(/\{(\w+)\}/g, (m, k) => vars[k] ?? m) : s.replace('{x}', () => vars);
|
|
8
|
+
}
|
|
9
|
+
export function numbers(lang) {
|
|
10
|
+
const nf = (min, max) => new Intl.NumberFormat(lang, { minimumFractionDigits: min, maximumFractionDigits: max, useGrouping: false });
|
|
11
|
+
const grouped = new Intl.NumberFormat(lang, { maximumFractionDigits: 0 });
|
|
12
|
+
const comma = nf(1, 1).format(0.5).includes(',');
|
|
13
|
+
// -0 is written as 0, and a negative number takes the real minus sign.
|
|
14
|
+
const sign = s => /^-0([.,]0*)?$/.test(s) ? s.slice(1) : s.replace(/^-/, MINUS);
|
|
15
|
+
return {
|
|
16
|
+
comma,
|
|
17
|
+
// fmt writes a number with up to max decimals, and fix with exactly n.
|
|
18
|
+
fmt: (n, max = 2) => sign(nf(0, max).format(n)),
|
|
19
|
+
fix: (n, digits) => sign(nf(digits, digits).format(n)),
|
|
20
|
+
// int writes a count with the language's grouping of thousands. fmt and fix write a measure, which has none.
|
|
21
|
+
int: n => sign(grouped.format(n)),
|
|
22
|
+
// A pair of coordinates takes a semicolon where the language writes decimals with a comma.
|
|
23
|
+
pair: (a, b, max = 2) => `(${sign(nf(0, max).format(a))}${comma ? '; ' : ', '}${sign(nf(0, max).format(b))})`,
|
|
24
|
+
// tex writes a number for KaTeX, which needs braces round a decimal comma and a plain minus.
|
|
25
|
+
tex: (n, max = 2) => nf(0, max).format(n).replace(/^-0([.,]0*)?$/, '0').replace(',', '{,}'),
|
|
26
|
+
// brace makes a number that is written already safe for KaTeX, which spaces a bare comma as punctuation.
|
|
27
|
+
brace: s => s.replace(/,/g, '{,}'),
|
|
28
|
+
// percent writes a share such as 0.25 as 25%, with the sign on the side the language puts it.
|
|
29
|
+
percent: (n, max = 0) => new Intl.NumberFormat(lang, { style: 'percent', maximumFractionDigits: max }).format(n),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
// aligned sets the steps of a worked formula under one another at their equals signs. The first step is the name
|
|
33
|
+
// and each later step starts with its relation, such as "= 12".
|
|
34
|
+
export const aligned = ([what, ...rest], gap = '0.4em') => `\\begin{aligned} ${what} &${rest.join(` \\\\[${gap}] &`)} \\end{aligned}`;
|
package/src/kit/goal.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// The line a challenge page shows above its controls: the goal in words, whether it is reached, a hint and another
|
|
2
|
+
// target. Every family judges with its own goal and shows the result here.
|
|
3
|
+
import { h, icon } from './dom.js';
|
|
4
|
+
import { button } from './panel.js';
|
|
5
|
+
|
|
6
|
+
// T gives the shared strings. hint is a function that shows or hides the family's hint and is left out on a page
|
|
7
|
+
// without one, and another moves to the next target. actions are more buttons for the line. A quiet line is for a
|
|
8
|
+
// page whose title states the goal: it has no goal text and says nothing until the goal is reached.
|
|
9
|
+
export function goalRow({ T, hint, another, motion, actions = [], quiet = false }) {
|
|
10
|
+
const text = h('p', { class: 'hesap-goal-text' }), state = h('span', { class: 'hesap-goal-state', role: 'status' });
|
|
11
|
+
const hintText = h('p', { class: 'hesap-hint', hidden: true });
|
|
12
|
+
let done = false, hinted = false;
|
|
13
|
+
// A hint is words, or an element the family built, such as a formula. kept says the hint opens again after a
|
|
14
|
+
// change of language, so the family shows it without marking it as new.
|
|
15
|
+
const toggle = kept => {
|
|
16
|
+
hinted = !hinted; hintBtn.setAttribute('aria-expanded', hinted);
|
|
17
|
+
const words = hint(hinted, kept); hintText.replaceChildren(...(words ? [words] : [])); hintText.hidden = !hinted || !words;
|
|
18
|
+
};
|
|
19
|
+
const hintBtn = hint ? button({ label: T('hint'), act: 'hint', press: () => toggle(false) }) : null;
|
|
20
|
+
hintBtn?.setAttribute('aria-expanded', 'false');
|
|
21
|
+
text.hidden = quiet;
|
|
22
|
+
const el = h('div', { class: `hesap-goal${quiet ? ' hesap-quiet' : ''}` }, [text, state, another ? button({ label: T('another'), act: 'another', press: another }) : null, hintBtn, ...actions, hintText].filter(Boolean));
|
|
23
|
+
return {
|
|
24
|
+
el, text, hintText,
|
|
25
|
+
// say writes the goal. A family that sets formulas in the goal writes into text itself.
|
|
26
|
+
say(words) { if (words instanceof Node) text.replaceChildren(words); else if (text.textContent !== (words ?? '')) text.textContent = words ?? ''; },
|
|
27
|
+
// show says whether the goal is reached. note is a line of progress for a goal not reached yet. It returns true
|
|
28
|
+
// the first time the goal is reached, when the family cheers.
|
|
29
|
+
show(reached, note) {
|
|
30
|
+
const words = reached ? T('solved') : note ?? (quiet ? '' : T('not-yet'));
|
|
31
|
+
if (state.dataset.words !== words) { state.dataset.words = words; state.replaceChildren(...(reached ? [icon('tick'), h('b', {}, words)] : [words])); }
|
|
32
|
+
el.classList.toggle('solved', reached);
|
|
33
|
+
const first = reached && !done; done = reached;
|
|
34
|
+
if (first) motion?.pop(state);
|
|
35
|
+
return first;
|
|
36
|
+
},
|
|
37
|
+
reached: () => done,
|
|
38
|
+
hinted: () => hinted,
|
|
39
|
+
// keep carries over the state of the line this one replaces, when a change of language builds the panel again.
|
|
40
|
+
// A goal reached already stays reached without its pop, and an open hint opens again.
|
|
41
|
+
keep(old) {
|
|
42
|
+
if (!old) return;
|
|
43
|
+
done = old.reached();
|
|
44
|
+
if (old.hinted() && hintBtn && !hinted) toggle(true);
|
|
45
|
+
},
|
|
46
|
+
// reset closes the hint and forgets the last result, for another target.
|
|
47
|
+
reset() { done = false; hinted = false; hintBtn?.setAttribute('aria-expanded', 'false'); hintText.hidden = true; },
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
hint: Move the figure and watch the numbers follow it.
|
|
2
|
+
tab_map: Figure
|
|
3
|
+
map_data: Data
|
|
4
|
+
map_view: View
|
|
5
|
+
chronology: Contents
|
|
6
|
+
layout_center: Figure in the middle
|
|
7
|
+
view_reset: Reset
|
|
8
|
+
hesap_start: Start
|
|
9
|
+
hesap_time: Time
|
|
10
|
+
hesap_reset: Start again
|
|
11
|
+
hesap_undo: Undo
|
|
12
|
+
hesap_hint: Hint
|
|
13
|
+
hesap_another: Another one
|
|
14
|
+
hesap_solved: Solved
|
|
15
|
+
hesap_not-yet: Not solved yet.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
hint: Şekli hareket ettirin ve sayıların onu izleyişine bakın.
|
|
2
|
+
tab_map: Şekil
|
|
3
|
+
map_data: Veri
|
|
4
|
+
map_view: Görünüm
|
|
5
|
+
chronology: İçindekiler
|
|
6
|
+
layout_center: Şekil ortada
|
|
7
|
+
view_reset: Sıfırla
|
|
8
|
+
hesap_start: Başlat
|
|
9
|
+
hesap_time: Zaman
|
|
10
|
+
hesap_reset: Baştan başla
|
|
11
|
+
hesap_undo: Geri al
|
|
12
|
+
hesap_hint: İpucu
|
|
13
|
+
hesap_another: Bir tane daha
|
|
14
|
+
hesap_solved: Çözüldü
|
|
15
|
+
hesap_not-yet: Henüz çözülmedi.
|
package/src/kit/kit.css
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/* Hesap has a layer of its own, so nothing in a figure rises over a phone's text. Each family draws inside its own
|
|
2
|
+
box, which fills the viewport while one of its pages shows. */
|
|
3
|
+
.hesap{position:absolute;inset:0;background:var(--paper);isolation:isolate;user-select:none;-webkit-user-select:none;font-family:var(--body);color:var(--ink)}
|
|
4
|
+
.hesap-family{position:absolute;inset:0;display:flex;flex-direction:column}
|
|
5
|
+
.hesap-family[hidden],.hesap-stage[hidden],.hesap-panel[hidden],.hesap-cover[hidden],.hesap-panel [hidden]{display:none}
|
|
6
|
+
.hesap-cover{position:absolute;inset:0;width:100%;height:100%;object-fit:contain}
|
|
7
|
+
.hesap-stage{flex:1;min-height:0;position:relative}
|
|
8
|
+
/* On a screen with room the readouts stand above the figure in large type. */
|
|
9
|
+
.hesap-head{padding:.857rem 1.143rem 0}
|
|
10
|
+
.hesap-head[hidden]{display:none}
|
|
11
|
+
.hesap-head .hesap-out{gap:.571rem 1.714rem;align-items:flex-end}
|
|
12
|
+
.hesap-head .hesap-chip{flex-direction:column;align-items:flex-start;gap:.071rem;border:0;border-radius:0;padding:0;background:none;box-shadow:none}
|
|
13
|
+
.hesap-head .hesap-chip small{font-size:.857rem}
|
|
14
|
+
.hesap-head .hesap-chip b{font-family:var(--display);font-size:2.286rem;line-height:1.1;text-align:start}
|
|
15
|
+
.hesap-head .hesap-chip.hot b,.hesap-head .hesap-chip[aria-pressed="true"] b{color:var(--accent)}
|
|
16
|
+
.hesap-head .hesap-btn{margin-inline-start:auto}
|
|
17
|
+
|
|
18
|
+
/* The panel under the figure holds a challenge's line, then the controls, then the readouts. */
|
|
19
|
+
.hesap-panel{position:relative;border-top:1px solid var(--rule);background:var(--panel);padding:.571rem .857rem;display:flex;flex-direction:column;gap:.5rem}
|
|
20
|
+
.hesap-ctls,.hesap-acts{display:flex;flex-wrap:wrap;gap:.429rem .857rem;align-items:center}
|
|
21
|
+
.hesap-acts{margin-inline-start:auto}
|
|
22
|
+
.hesap-out{display:flex;flex-wrap:wrap;gap:.357rem .429rem;align-items:center}
|
|
23
|
+
.hesap-panel .hot{outline:2px solid var(--accent);outline-offset:2px}
|
|
24
|
+
|
|
25
|
+
/* A slider takes the room the other controls leave on its row. */
|
|
26
|
+
.hesap-ctl{flex:1 1 14rem;display:flex;align-items:center;gap:.571rem;min-height:44px;border-radius:6px}
|
|
27
|
+
.hesap-ctl span{color:var(--ink-2);white-space:nowrap}
|
|
28
|
+
.hesap-ctl input{flex:1;min-width:0;min-height:44px;margin:0;accent-color:var(--accent)}
|
|
29
|
+
.hesap-ctl output{font-variant-numeric:tabular-nums;font-weight:700;text-align:end;min-width:3ch}
|
|
30
|
+
|
|
31
|
+
.hesap-btn,.hesap-seg button,.hesap-step button{min-height:44px;min-width:44px;border:1px solid var(--rule);background:var(--paper);color:var(--ink);font:inherit;cursor:pointer;border-radius:6px;display:inline-flex;align-items:center;justify-content:center;gap:.357rem;padding:0 .714rem;white-space:nowrap}
|
|
32
|
+
.hesap-btn:disabled,.hesap-step button:disabled{opacity:.45;cursor:default}
|
|
33
|
+
.hesap-icon{width:18px;height:18px;flex:none}
|
|
34
|
+
:is(.hesap-btn,.hesap-seg button,.hesap-step button,.hesap-chip):focus-visible{outline:2px solid var(--accent);outline-offset:2px}
|
|
35
|
+
.hesap-btn[aria-pressed="true"]{background:var(--ink);color:var(--paper);border-color:var(--ink)}
|
|
36
|
+
/* The one button that starts something stands out. */
|
|
37
|
+
.hesap-primary{background:var(--accent);border-color:var(--accent);color:var(--paper);font-weight:700;padding:0 1.143rem}
|
|
38
|
+
|
|
39
|
+
.hesap-seg{display:inline-flex;align-items:center}
|
|
40
|
+
.hesap-seg-name{color:var(--ink-2);font-size:.857rem;margin-inline-end:.429rem}
|
|
41
|
+
.hesap-seg button{border-radius:0;margin-inline-start:-1px;font-variant-numeric:tabular-nums;padding:0 .571rem}
|
|
42
|
+
.hesap-seg button:first-of-type{border-start-start-radius:6px;border-end-start-radius:6px;margin-inline-start:0}
|
|
43
|
+
.hesap-seg button:last-of-type{border-start-end-radius:6px;border-end-end-radius:6px}
|
|
44
|
+
.hesap-seg button[aria-pressed="true"]{background:var(--ink);color:var(--paper);border-color:var(--ink);position:relative}
|
|
45
|
+
|
|
46
|
+
.hesap-step{display:inline-flex;align-items:center;gap:.357rem}
|
|
47
|
+
.hesap-step span{color:var(--ink-2);margin-inline-end:.214rem}
|
|
48
|
+
.hesap-step output{min-width:2.5ch;text-align:center;font-weight:700;font-variant-numeric:tabular-nums}
|
|
49
|
+
|
|
50
|
+
.hesap-chip{display:inline-flex;gap:.429rem;align-items:baseline;border:1px solid var(--rule);border-radius:999px;padding:.286rem .786rem;background:var(--paper);color:var(--ink);font:inherit}
|
|
51
|
+
button.hesap-chip{cursor:pointer;min-height:36px;align-items:center}
|
|
52
|
+
.hesap-chip small{color:var(--ink-2);font-size:.857rem;white-space:nowrap}
|
|
53
|
+
.hesap-chip b{font-variant-numeric:tabular-nums;text-align:end}
|
|
54
|
+
.hesap-swatch{width:.714rem;height:.714rem;border-radius:50%;flex:none;align-self:center;background:currentColor}
|
|
55
|
+
.hesap-short{display:none}
|
|
56
|
+
.hesap-chip.hot{outline:none;border-color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent)}
|
|
57
|
+
.hesap-chip[aria-pressed="true"]{border-color:var(--ink);box-shadow:inset 0 0 0 1px var(--ink)}
|
|
58
|
+
|
|
59
|
+
/* A challenge's line holds the goal, whether it is reached, another target and a hint. The goal takes a line of its
|
|
60
|
+
own, so a longer status keeps the panel's height. */
|
|
61
|
+
.hesap-goal{display:flex;flex-wrap:wrap;align-items:center;gap:.286rem .571rem}
|
|
62
|
+
.hesap-goal-text{margin:0;flex-basis:100%;font-weight:600}
|
|
63
|
+
.hesap-goal-state{display:inline-flex;align-items:center;gap:.286rem;color:var(--ink-2);flex:1;min-width:0}
|
|
64
|
+
.hesap-goal.solved .hesap-goal-state{color:var(--accent)}
|
|
65
|
+
.hesap-goal-state svg{width:20px;height:20px}
|
|
66
|
+
.hesap-hint{margin:0;flex-basis:100%;color:var(--ink-2)}
|
|
67
|
+
.hesap-hint[hidden]{display:none}
|
|
68
|
+
|
|
69
|
+
/* The values in the text follow the figure. A worked formula takes its own line, and scrolls sideways on a narrow
|
|
70
|
+
screen. */
|
|
71
|
+
aside.story .place[data-live]{font-variant-numeric:tabular-nums;font-weight:700}
|
|
72
|
+
aside.story .place[data-formula],aside.story .place[data-formula]:is(:hover,:focus-visible,.on){display:block;text-decoration:none;background:none;overflow-x:auto;overflow-y:hidden;padding:.143rem 0}
|
|
73
|
+
aside.story .place[data-formula] .katex-display{margin:0;text-align:start}
|
|
74
|
+
aside.story .place[data-formula] .katex-display>.katex{text-align:start}
|
|
75
|
+
|
|
76
|
+
@media (max-width:900px){
|
|
77
|
+
.hesap-panel{padding:.429rem .571rem;gap:.357rem}
|
|
78
|
+
.hesap-ctls,.hesap-acts{gap:.286rem .571rem}
|
|
79
|
+
.hesap-btn,.hesap-seg button,.hesap-step button{min-height:42px}
|
|
80
|
+
.hesap-chip{padding:.214rem .643rem}
|
|
81
|
+
.hesap-chip small{font-size:.786rem}
|
|
82
|
+
.hesap-long{display:none}
|
|
83
|
+
.hesap-short{display:inline}
|
|
84
|
+
/* A compact button shows its glyph alone. */
|
|
85
|
+
.hesap-compact{min-width:44px;padding:0}
|
|
86
|
+
.hesap-compact span{display:none}
|
|
87
|
+
/* The peek card sits above the panel. A figure stays clear of the card by leaving --hesap-peek free at its foot. */
|
|
88
|
+
.peek{bottom:calc(var(--hesap-panel,0px) + .571rem)}
|
|
89
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// A tracker runs anime.js animations and remembers the ones still running, so a page change can stop them all.
|
|
2
|
+
// Times are in milliseconds.
|
|
3
|
+
export function tracker() {
|
|
4
|
+
// live maps each running animation to what runs when a page change cuts it short.
|
|
5
|
+
const { animate, createTimeline, stagger } = window.anime, live = new Map(), groups = new Set();
|
|
6
|
+
// CSS transforms on SVG scale and turn an element about its own middle.
|
|
7
|
+
const centre = els => { for (const e of [els].flat()) if (e?.style) { e.style.transformBox = 'fill-box'; e.style.transformOrigin = 'center'; } return els; };
|
|
8
|
+
// anime.js keeps one then for each animation, so an animation ends through onComplete and done runs there. A
|
|
9
|
+
// run that stop cuts short never reaches done, and cut runs in its place, to take away what the run added.
|
|
10
|
+
function run(targets, params, done, cut) {
|
|
11
|
+
const a = animate(targets, { ...params, onComplete: () => { live.delete(a); params.onComplete?.(); done?.(); } });
|
|
12
|
+
live.set(a, cut);
|
|
13
|
+
return a;
|
|
14
|
+
}
|
|
15
|
+
// An effect on an element that stays on the page goes back to where it began when it is cut short.
|
|
16
|
+
const effect = (targets, params) => { const a = run(targets, params, null, () => a.revert()); return a; };
|
|
17
|
+
// timeline runs phases one after another. Each phase is the params of one animation with its targets.
|
|
18
|
+
function timeline(phases, done, defaults = {}, cut) {
|
|
19
|
+
const tl = createTimeline({ defaults, onComplete: () => { live.delete(tl); done?.(); } });
|
|
20
|
+
for (const { targets, at, ...params } of phases) tl.add(targets, params, at);
|
|
21
|
+
live.set(tl, cut);
|
|
22
|
+
return tl;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
run, timeline, stagger, centre,
|
|
26
|
+
// group gives a tracker of its own, so a family can stop one kind of animation and let the others run. The
|
|
27
|
+
// page's stop ends every group too.
|
|
28
|
+
group() { const g = tracker(); groups.add(g); return g; },
|
|
29
|
+
stop() {
|
|
30
|
+
const cuts = [...live];
|
|
31
|
+
live.clear();
|
|
32
|
+
for (const [a, cut] of cuts) { a.pause(); cut?.(); }
|
|
33
|
+
for (const g of groups) g.stop();
|
|
34
|
+
},
|
|
35
|
+
// adopt prepares every element of class a under root for scaling about its middle.
|
|
36
|
+
adopt(root) { centre([...root.querySelectorAll('.a')]); },
|
|
37
|
+
// A value that changed jumps once.
|
|
38
|
+
flash: el => effect(centre(el), { scale: [1, 1.08, 1], duration: 320, ease: 'outQuad' }),
|
|
39
|
+
pop: el => effect(centre(el), { scale: [1, 1.25, 1], duration: 320, ease: 'outQuad' }),
|
|
40
|
+
pulse: el => effect(centre(el), { scale: [1, 1.08, 1], duration: 420, ease: 'outQuad' }),
|
|
41
|
+
// The parts that reach a goal swell once, one after another.
|
|
42
|
+
cheer: els => els.length ? effect(centre(els), { scale: [1, 1.2, 1], duration: 520, delay: stagger(Math.min(60, 400 / els.length)), ease: 'outBack' }) : null,
|
|
43
|
+
};
|
|
44
|
+
}
|