histropediajs 1.5.0 → 1.6.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 +8 -8
- package/README.md +619 -499
- package/dist/histropedia.esm.js +2254 -524
- package/dist/histropedia.umd.js +2273 -538
- package/dist/histropedia.umd.min.js +2 -2
- package/index.d.ts +1883 -1718
- package/package.json +101 -101
package/README.md
CHANGED
|
@@ -1,499 +1,619 @@
|
|
|
1
|
-
# HistropediaJS
|
|
2
|
-
|
|
3
|
-
An embeddable, high-performance, canvas-based timeline engine for rendering events (known as "articles" in the library) over timescales from
|
|
4
|
-
|
|
5
|
-
- **Canvas-based**: fast rendering and smooth animations
|
|
6
|
-
- **Huge ranges**:
|
|
7
|
-
- **Customizable**: styles, layouts, stacking, density, branding
|
|
8
|
-
- **Modular**: ESM default build + UMD for script tags
|
|
9
|
-
|
|
10
|
-
## Installation
|
|
11
|
-
|
|
12
|
-
```bash
|
|
13
|
-
npm install histropediajs
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
### Documentation
|
|
17
|
-
|
|
18
|
-
For comprehensive guides, options reference, and API docs, see the hosted documentation: [HistropediaJS Documentation](https://js.histropedia.com/documentation).
|
|
19
|
-
|
|
20
|
-
### Importing
|
|
21
|
-
|
|
22
|
-
`histropediajs` is published as an ESM package. Use `import` in bundlers or ESM-capable runtimes. `require('histropediajs')` is not supported. For non-module browser usage, load the UMD bundle with a `<script>` tag.
|
|
23
|
-
|
|
24
|
-
- ESM (npm / bundlers, recommended):
|
|
25
|
-
|
|
26
|
-
```js
|
|
27
|
-
import Histropedia from 'histropediajs';
|
|
28
|
-
// or named exports when you only need part of the public API
|
|
29
|
-
import { Timeline, Article, Chart, Dmy, Logger } from 'histropediajs';
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
The package entry point is a bundled ESM file, so named imports are mainly for clarity and smaller application bundles when your bundler can remove unused exports. They do not expose separate per-module entry points.
|
|
33
|
-
|
|
34
|
-
- UMD (script tag) via CDN or self-host:
|
|
35
|
-
- CDN (jsDelivr):
|
|
36
|
-
|
|
37
|
-
```html
|
|
38
|
-
<script src="https://cdn.jsdelivr.net/npm/histropediajs@1/dist/histropedia.umd.min.js"></script>
|
|
39
|
-
<script>
|
|
40
|
-
const { Timeline, Dmy } = Histropedia; // global
|
|
41
|
-
// window.Histropedia is also available
|
|
42
|
-
</script>
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
- Self-host (copy dist file into your public assets during build):
|
|
46
|
-
|
|
47
|
-
```html
|
|
48
|
-
<script src="/assets/vendor/histropedia.umd.js"></script>
|
|
49
|
-
<script>
|
|
50
|
-
const { Timeline, Dmy } = Histropedia;
|
|
51
|
-
</script>
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Quick start
|
|
55
|
-
|
|
56
|
-
```html
|
|
57
|
-
<div id="timeline"></div>
|
|
58
|
-
<script type="module">
|
|
59
|
-
import { Timeline } from 'histropediajs';
|
|
60
|
-
|
|
61
|
-
const container = document.getElementById('timeline');
|
|
62
|
-
const options = {
|
|
63
|
-
width: 1000,
|
|
64
|
-
height: 500,
|
|
65
|
-
initialDate: { year: 1990, month: 1, day: 1 },
|
|
66
|
-
zoom: { initial: 34 },
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const timeline = new Timeline(container, options);
|
|
70
|
-
|
|
71
|
-
timeline.load([
|
|
72
|
-
{
|
|
73
|
-
id: 'apollo11',
|
|
74
|
-
title: 'Apollo 11',
|
|
75
|
-
subtitle: 'First Moon landing',
|
|
76
|
-
from: { year: 1969, month: 7, day: 16 },
|
|
77
|
-
to: { year: 1969, month: 7, day: 24 },
|
|
78
|
-
imageUrl: 'https://example.com/apollo11.jpg',
|
|
79
|
-
},
|
|
80
|
-
]);
|
|
81
|
-
</script>
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## Data model
|
|
85
|
-
|
|
86
|
-
Each article (event) uses the following minimal shape. Short property aliases are also supported internally for compact data, but prefer the long form in your code.
|
|
87
|
-
|
|
88
|
-
```js
|
|
89
|
-
{
|
|
90
|
-
id: string|number,
|
|
91
|
-
title: string,
|
|
92
|
-
subtitle?: string,
|
|
93
|
-
lane?: string|number,
|
|
94
|
-
from: {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
Histropedia
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
-
|
|
493
|
-
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
1
|
+
# HistropediaJS
|
|
2
|
+
|
|
3
|
+
An embeddable, high-performance, canvas-based timeline engine for rendering events (known as "articles" in the library) over timescales from milliseconds to billions of years. Offers smooth pan/zoom, stacking, card layouts, time bands, image loading, and a flexible API.
|
|
4
|
+
|
|
5
|
+
- **Canvas-based**: fast rendering and smooth animations
|
|
6
|
+
- **Huge ranges**: millisecond -> billion-year scales, BCE support
|
|
7
|
+
- **Customizable**: styles, layouts, stacking, density, branding
|
|
8
|
+
- **Modular**: ESM default build + UMD for script tags
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install histropediajs
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Documentation
|
|
17
|
+
|
|
18
|
+
For comprehensive guides, options reference, and API docs, see the hosted documentation: [HistropediaJS Documentation](https://js.histropedia.com/documentation).
|
|
19
|
+
|
|
20
|
+
### Importing
|
|
21
|
+
|
|
22
|
+
`histropediajs` is published as an ESM package. Use `import` in bundlers or ESM-capable runtimes. `require('histropediajs')` is not supported. For non-module browser usage, load the UMD bundle with a `<script>` tag.
|
|
23
|
+
|
|
24
|
+
- ESM (npm / bundlers, recommended):
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
import Histropedia from 'histropediajs';
|
|
28
|
+
// or named exports when you only need part of the public API
|
|
29
|
+
import { Timeline, Article, Chart, Dmy, Logger } from 'histropediajs';
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The package entry point is a bundled ESM file, so named imports are mainly for clarity and smaller application bundles when your bundler can remove unused exports. They do not expose separate per-module entry points.
|
|
33
|
+
|
|
34
|
+
- UMD (script tag) via CDN or self-host:
|
|
35
|
+
- CDN (jsDelivr):
|
|
36
|
+
|
|
37
|
+
```html
|
|
38
|
+
<script src="https://cdn.jsdelivr.net/npm/histropediajs@1/dist/histropedia.umd.min.js"></script>
|
|
39
|
+
<script>
|
|
40
|
+
const { Timeline, Dmy } = Histropedia; // global
|
|
41
|
+
// window.Histropedia is also available
|
|
42
|
+
</script>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
- Self-host (copy dist file into your public assets during build):
|
|
46
|
+
|
|
47
|
+
```html
|
|
48
|
+
<script src="/assets/vendor/histropedia.umd.js"></script>
|
|
49
|
+
<script>
|
|
50
|
+
const { Timeline, Dmy } = Histropedia;
|
|
51
|
+
</script>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Quick start
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<div id="timeline"></div>
|
|
58
|
+
<script type="module">
|
|
59
|
+
import { Timeline } from 'histropediajs';
|
|
60
|
+
|
|
61
|
+
const container = document.getElementById('timeline');
|
|
62
|
+
const options = {
|
|
63
|
+
width: 1000,
|
|
64
|
+
height: 500,
|
|
65
|
+
initialDate: { year: 1990, month: 1, day: 1 },
|
|
66
|
+
zoom: { initial: 34 },
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const timeline = new Timeline(container, options);
|
|
70
|
+
|
|
71
|
+
timeline.load([
|
|
72
|
+
{
|
|
73
|
+
id: 'apollo11',
|
|
74
|
+
title: 'Apollo 11',
|
|
75
|
+
subtitle: 'First Moon landing',
|
|
76
|
+
from: { year: 1969, month: 7, day: 16 },
|
|
77
|
+
to: { year: 1969, month: 7, day: 24 },
|
|
78
|
+
imageUrl: 'https://example.com/apollo11.jpg',
|
|
79
|
+
},
|
|
80
|
+
]);
|
|
81
|
+
</script>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Data model
|
|
85
|
+
|
|
86
|
+
Each article (event) uses the following minimal shape. Short property aliases are also supported internally for compact data, but prefer the long form in your code.
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
{
|
|
90
|
+
id: string|number,
|
|
91
|
+
title: string,
|
|
92
|
+
subtitle?: string,
|
|
93
|
+
lane?: string|number,
|
|
94
|
+
from: {
|
|
95
|
+
year: number,
|
|
96
|
+
month?: number,
|
|
97
|
+
day?: number,
|
|
98
|
+
hour?: number,
|
|
99
|
+
minute?: number,
|
|
100
|
+
second?: number,
|
|
101
|
+
millisecond?: number,
|
|
102
|
+
precision?: string
|
|
103
|
+
},
|
|
104
|
+
to?: { /* same date/time fields as from */ },
|
|
105
|
+
isToPresent?: boolean,
|
|
106
|
+
rank?: number,
|
|
107
|
+
starred?: boolean,
|
|
108
|
+
hidePeriodLine?: boolean,
|
|
109
|
+
hiddenByFilter?: boolean,
|
|
110
|
+
imageUrl?: string,
|
|
111
|
+
cardLayout?: 'portrait' | 'landscape',
|
|
112
|
+
style?: object,
|
|
113
|
+
hoverStyle?: object,
|
|
114
|
+
activeStyle?: object
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Notes:
|
|
119
|
+
|
|
120
|
+
- BCE years are supported with negative year values; internally year 0 represents 1 BCE. Set `shiftBceDates: true` to shift year input by 1 so that -1 is 1BCE.
|
|
121
|
+
- Precision accepts `millisecond`, `second`, `minute`, `hour`, `day`, `month`, `year`, `decade`, `century`, `millennium`, `million-years`, and `billion-years`. The exported `Histropedia.PRECISION_*` constants resolve to these strings. Legacy numeric precision values remain supported but are deprecated.
|
|
122
|
+
- If `to` is omitted and `isToPresent` is false, the article is treated as an instant event (uses `from`), but the `from.precision` determines the span of the period line.
|
|
123
|
+
- Full precision boundary rules and examples: [docs/date-precision.md](docs/date-precision.md)
|
|
124
|
+
|
|
125
|
+
## Main line styling
|
|
126
|
+
|
|
127
|
+
The main line uses a flat neutral fill by default. Set `style.mainLine.color` to any CSS colour
|
|
128
|
+
string for a solid fill, or use a gradient object for a vertical top-to-bottom gradient. Article
|
|
129
|
+
date indicators are configured through `style.mainLine.dateIndicators`:
|
|
130
|
+
|
|
131
|
+
```js
|
|
132
|
+
const timeline = new Timeline(container, {
|
|
133
|
+
style: {
|
|
134
|
+
mainLine: {
|
|
135
|
+
color: {
|
|
136
|
+
type: 'gradient',
|
|
137
|
+
topColor: '#808080',
|
|
138
|
+
bottomColor: '#ccc',
|
|
139
|
+
},
|
|
140
|
+
dateIndicators: {
|
|
141
|
+
visible: true,
|
|
142
|
+
shape: 'circle',
|
|
143
|
+
size: 6,
|
|
144
|
+
color: 'article',
|
|
145
|
+
hiddenStyle: {
|
|
146
|
+
opacity: 0.4,
|
|
147
|
+
},
|
|
148
|
+
activeStyle: {
|
|
149
|
+
color: 'article',
|
|
150
|
+
size: 8,
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
The example above preserves the gradient colours used by earlier HistropediaJS versions. Use a
|
|
159
|
+
string such as `color: '#d9dde3'` to select solid rendering; no separate gradient switch is needed.
|
|
160
|
+
Date indicator shapes can be `rectangle` (the default) or `circle`; `size` is the rectangle width
|
|
161
|
+
or circle diameter. Rectangles span the main line's thickness, retaining the original date-tick
|
|
162
|
+
geometry. Use any CSS colour, or `color: 'article'` to use each article's normal card colour without
|
|
163
|
+
reacting to its hover style. `hiddenStyle` and `activeStyle` are sparse overrides used only for
|
|
164
|
+
density-hidden and active/selected articles respectively, so omitted properties continue to use
|
|
165
|
+
the base indicator settings. Within `activeStyle`, `color: 'article'` uses the card's resolved active
|
|
166
|
+
colour; the same value in the base or hidden style uses its resolved normal colour. Indicator
|
|
167
|
+
`opacity` accepts values from `0` to `1`.
|
|
168
|
+
|
|
169
|
+
## Parent context date labels
|
|
170
|
+
|
|
171
|
+
Set `style.dateLabel.parent.visible` to `true` to add a persistent calendar-parent row beneath the
|
|
172
|
+
existing major labels. The row is disabled by default, supports declarative `'auto'`, `'all'`, or
|
|
173
|
+
explicit scale levels, and reserves its configured height at every scale while enabled. See
|
|
174
|
+
[docs/parent-date-labels.md](docs/parent-date-labels.md) for configuration and scale behaviour.
|
|
175
|
+
|
|
176
|
+
## Lanes
|
|
177
|
+
|
|
178
|
+
Use `lane` when you need multiple horizontal event rows that share the same bottom axis. Articles, connectors, hit-testing, and period lines still render on the shared canvas, while lane headers, titles, and bodies render as DOM elements underneath the canvas so they can be styled independently. By default, period lines anchor to each lane bottom while lane layout is active; set `article.periodLine.position = 'axis'` to keep the legacy shared-axis behavior.
|
|
179
|
+
|
|
180
|
+
```js
|
|
181
|
+
const timeline = new Timeline(container, {
|
|
182
|
+
lane: {
|
|
183
|
+
defaultClassName: 'timeline-lane',
|
|
184
|
+
defaultHeaderClassName: 'timeline-lane-header',
|
|
185
|
+
defaultBodyClassName: 'timeline-lane-body',
|
|
186
|
+
defaultTitleClassName: 'timeline-lane-title',
|
|
187
|
+
data: [
|
|
188
|
+
{ id: 'people', title: 'People', layout: { heightWeight: 2 } },
|
|
189
|
+
{ id: 'projects', title: 'Projects', layout: { heightWeight: 1 } },
|
|
190
|
+
],
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
timeline.load([
|
|
195
|
+
{
|
|
196
|
+
id: 'ada',
|
|
197
|
+
lane: 'people',
|
|
198
|
+
title: 'Ada Lovelace',
|
|
199
|
+
from: { year: 1815, month: 12, day: 10 },
|
|
200
|
+
},
|
|
201
|
+
]);
|
|
202
|
+
|
|
203
|
+
timeline.loadLaneArticles('projects', [
|
|
204
|
+
{
|
|
205
|
+
id: 'analytical-engine',
|
|
206
|
+
title: 'Analytical Engine',
|
|
207
|
+
from: { year: 1837 },
|
|
208
|
+
},
|
|
209
|
+
]);
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
- Lane geometry stays inline so the renderer can place each lane correctly, but decorative inline styles are only written when you explicitly configure `lane.defaultStyle` or `LaneData.style`.
|
|
213
|
+
- Lane roots always include `histropedia-lane`, `histropedia-lane-index-N`, and a position class, where `N` follows the stable `timeline.lanes` order from the axis outward.
|
|
214
|
+
- Lower lanes stack above upper lanes with inline `z-index` values, making stacked CSS effects easier to write.
|
|
215
|
+
- `timeline.articles` stays flat across all lanes for backward compatibility.
|
|
216
|
+
- `ArticleData.lane` is the primary way to place events; omitted values fall back to `options.lane.defaultId` (`'default'`).
|
|
217
|
+
- `lane.topGap` reserves space above the topmost lane and reduces the height available for lane layout.
|
|
218
|
+
- `lane.axisGap` controls the space between the painted top edge of the shared main line and the lane area. Set it to `0` if the nearest lane body should meet the main line.
|
|
219
|
+
- `lane.layout.heightWeight` distributes the remaining automatic lane height across visible lanes only. Omit it to keep the default equal split, or use `lane.layout.height` for a fixed lane height.
|
|
220
|
+
- `timeline.loadLanes(...)` adds or updates lane definitions, including implicit lanes created from article data.
|
|
221
|
+
- Per-lane article defaults live under `lane.article` and merge over global `options.article` presentation defaults.
|
|
222
|
+
|
|
223
|
+
## API
|
|
224
|
+
|
|
225
|
+
### Default export
|
|
226
|
+
|
|
227
|
+
```js
|
|
228
|
+
import Histropedia from 'histropediajs';
|
|
229
|
+
// Histropedia = { Timeline, Article, Chart, Lane, TimeBand, Dmy, Logger, ...constants, ...sorters, setDebug, isDebugEnabled, enableDebug, disableDebug }
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Classes and utilities
|
|
233
|
+
|
|
234
|
+
- **Timeline**: main canvas timeline. `new Timeline(containerOrCanvas, options)`
|
|
235
|
+
- **Article**: article model used internally; available for advanced usage
|
|
236
|
+
- **Dmy**: lightweight date/time helper (millisecond precision and BCE support)
|
|
237
|
+
- **Logger**: centralized console logger with `setEnabled(boolean)`
|
|
238
|
+
- **Constants**: zoom levels, precisions, density controls, etc.
|
|
239
|
+
|
|
240
|
+
### Timeline constructor
|
|
241
|
+
|
|
242
|
+
```ts
|
|
243
|
+
new Timeline(container: HTMLElement | HTMLCanvasElement, options?: TimelineOptions)
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
If `container` is an element, the timeline creates and appends its own `<canvas>`. If you pass a `<canvas>`, it will use it directly and derive width from the element unless overridden.
|
|
247
|
+
|
|
248
|
+
### Core methods
|
|
249
|
+
|
|
250
|
+
- `load(articles: ArticleInput[])`: load or append articles (deduplicates by `id`).
|
|
251
|
+
- `loadLanes(lanes: LaneData[])`: add or update lane definitions.
|
|
252
|
+
- `loadLaneArticles(laneId, articles)`: stamp a lane id onto a batch and forward to `load(...)`.
|
|
253
|
+
- `loadTimeBands(...)`: add timeline-wide background bands.
|
|
254
|
+
- `loadCharts(...)`: add time-series charts; duplicate ids are skipped with a warning.
|
|
255
|
+
- `loadLaneCharts(laneId, charts)`: stamp a lane id onto a batch and forward to `loadCharts(...)`.
|
|
256
|
+
- `setStartDate(date, options?)`: set the left edge date. `date` accepts a `Dmy`-compatible object or date string; use `options.padding` to place that date away from the left edge, and `options.animation` for animated movement.
|
|
257
|
+
- `setCentreDate(date, pixelOffset?)`: center the given date.
|
|
258
|
+
- `fitDateRange(start, end, options?)`: fit object, `Dmy`, or canonical date-string inputs, including millisecond ranges.
|
|
259
|
+
- `setSize(width: number, height: number)`: resize canvas and reflow.
|
|
260
|
+
- `setZoom(level: number, pivotPixel?: number, offsetX?: number)`: programmatic zoom.
|
|
261
|
+
- `on(event: string, handler)` / `off(event, handler)` / `trigger(event, ...args)`: event system.
|
|
262
|
+
- `select(articleId)`: bring to the front and trigger the `article-select` event.
|
|
263
|
+
|
|
264
|
+
### Events
|
|
265
|
+
|
|
266
|
+
Register handlers using `timeline.on(name, callback)` or pass `options.on = { [name]: handler }`.
|
|
267
|
+
|
|
268
|
+
Full list of events and payloads: [docs/events.md](docs/events.md)
|
|
269
|
+
|
|
270
|
+
Basic usage:
|
|
271
|
+
|
|
272
|
+
```js
|
|
273
|
+
// Register a handler
|
|
274
|
+
timeline.on('article-click', (article, evt) => {
|
|
275
|
+
console.log('article-click', article, evt);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// Or via options
|
|
279
|
+
const timeline = new Timeline(container, {
|
|
280
|
+
on: {
|
|
281
|
+
'article-click': (article, evt) => console.log('article-click', article, evt),
|
|
282
|
+
},
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
// Trigger an event programmatically (advanced)
|
|
286
|
+
timeline.trigger('my-custom-event', { any: 'payload' });
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Debugging and logging
|
|
290
|
+
|
|
291
|
+
HistropediaJS uses a centralized `Logger` service to control console output. Logging is **disabled by default** so it will not spam your console unless you explicitly turn it on.
|
|
292
|
+
|
|
293
|
+
`Histropedia.setDebug()` and the other global debug helpers control logging only. They do not enable visual canvas diagnostics. Visual debug overlays are configured per timeline and are disabled by default:
|
|
294
|
+
|
|
295
|
+
```js
|
|
296
|
+
const timeline = new Histropedia.Timeline(container, {
|
|
297
|
+
debugOverlays: {
|
|
298
|
+
densityRegions: true,
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
`debugOverlays.densityRegions` draws non-interactive vertical guides over the timeline at the current article-density region boundaries. It does not change density filtering, stacking, interaction, selection, or saved timeline data.
|
|
304
|
+
|
|
305
|
+
- **Enable / disable debug logging (default export helpers)**:
|
|
306
|
+
|
|
307
|
+
```js
|
|
308
|
+
import Histropedia from 'histropediajs';
|
|
309
|
+
|
|
310
|
+
// Turn on all HistropediaJS logging
|
|
311
|
+
Histropedia.enableDebug();
|
|
312
|
+
|
|
313
|
+
// Or explicitly set the flag
|
|
314
|
+
Histropedia.setDebug(true);
|
|
315
|
+
|
|
316
|
+
// Later, turn logging off again
|
|
317
|
+
Histropedia.disableDebug();
|
|
318
|
+
// Equivalent:
|
|
319
|
+
Histropedia.setDebug(false);
|
|
320
|
+
|
|
321
|
+
// Check current state
|
|
322
|
+
const isOn = Histropedia.isDebugEnabled(); // boolean
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
- **Using the `Logger` directly (ESM / bundlers)**:
|
|
326
|
+
|
|
327
|
+
```js
|
|
328
|
+
import { Logger } from 'histropediajs';
|
|
329
|
+
|
|
330
|
+
Logger.setEnabled(true); // enable logging
|
|
331
|
+
Logger.debug('Timeline initialised');
|
|
332
|
+
Logger.info('Loaded articles', articles);
|
|
333
|
+
Logger.warn('Something looks odd');
|
|
334
|
+
Logger.error('Something went wrong', err);
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
- **UMD / script-tag usage**:
|
|
338
|
+
|
|
339
|
+
```html
|
|
340
|
+
<script src="https://cdn.jsdelivr.net/npm/histropediajs@1/dist/histropedia.umd.min.js"></script>
|
|
341
|
+
<script>
|
|
342
|
+
// Enable debug logging
|
|
343
|
+
Histropedia.enableDebug();
|
|
344
|
+
|
|
345
|
+
// Or via the Logger instance
|
|
346
|
+
Histropedia.Logger.setEnabled(true);
|
|
347
|
+
Histropedia.Logger.debug('Timeline ready');
|
|
348
|
+
</script>
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
- **Changing the debug label (prefix / "suffix" tag)**:
|
|
352
|
+
|
|
353
|
+
All log messages are prefixed with a label (by default `[Histropedia]`) so you can easily spot them in the console. You can change this to include your app name, environment, or any other marker.
|
|
354
|
+
|
|
355
|
+
```js
|
|
356
|
+
import { Logger } from 'histropediajs';
|
|
357
|
+
|
|
358
|
+
// Set a custom label that will appear in front of every log message
|
|
359
|
+
Logger.setPrefix('[MyApp Timeline]');
|
|
360
|
+
|
|
361
|
+
Logger.setEnabled(true);
|
|
362
|
+
Logger.debug('Loading articles...');
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
For script-tag/UMD usage:
|
|
366
|
+
|
|
367
|
+
```js
|
|
368
|
+
Histropedia.Logger.setPrefix('[MyApp Timeline]');
|
|
369
|
+
Histropedia.enableDebug();
|
|
370
|
+
Histropedia.Logger.info('Timeline is ready');
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
The prefix is applied to all standard console-style methods exposed by the logger (`log`, `info`, `warn`, `error`, `debug`, `group`, `groupCollapsed`, `groupEnd`).
|
|
374
|
+
|
|
375
|
+
## Options
|
|
376
|
+
|
|
377
|
+
TimelineOptions tunes layout, interaction, article rendering, and image loading. Start with the defaults and override only what you need for your embed.
|
|
378
|
+
|
|
379
|
+
- **Layout**: adjust `width`, `height`, and `verticalOffset` to size and position the canvas.
|
|
380
|
+
- **Navigation**: set `initialDate`, `zoom.initial`, and `enableUserControl` to define how people explore the timeline.
|
|
381
|
+
- **Articles**: control stacking and presentation with `article.autoStacking`, adaptive `defaultCardLayout`, `cardLayoutBreakpoints`, `distanceToBaseline`, and density settings.
|
|
382
|
+
- **Lanes**: use `lane.defaultStyle`, `lane.data`, and per-lane `article` overrides for shared-axis multi-lane layouts.
|
|
383
|
+
- **Charts**: use `chart.data` or `loadCharts(...)` for read-only line charts, with optional `lane` placement.
|
|
384
|
+
- **Images**: use `image.sanitizer.allowedOrigins`, caching limits, or a custom `image.customSanitizer` to match your content policies.
|
|
385
|
+
- **Events**: register callbacks via the `on` map or helpers such as `onArticleClick`.
|
|
386
|
+
|
|
387
|
+
Find the full option reference, defaults, and advanced patterns in the hosted docs: https://js.histropedia.com/documentation.
|
|
388
|
+
|
|
389
|
+
### Sub-day zoom
|
|
390
|
+
|
|
391
|
+
Sub-day zoom is opt-in, so existing timelines keep exactly the same minimum scale. The default
|
|
392
|
+
`zoom.minimum` remains `0`, where one day is the finest timescale unit. Set it to a negative value
|
|
393
|
+
to allow continuous zoom through hours, minutes, seconds, and milliseconds:
|
|
394
|
+
|
|
395
|
+
```js
|
|
396
|
+
const timeline = new Timeline(container, {
|
|
397
|
+
initialDate: {
|
|
398
|
+
year: 2026,
|
|
399
|
+
month: 8,
|
|
400
|
+
day: 13,
|
|
401
|
+
hour: 12,
|
|
402
|
+
minute: 30,
|
|
403
|
+
second: 15,
|
|
404
|
+
millisecond: 250,
|
|
405
|
+
},
|
|
406
|
+
zoom: {
|
|
407
|
+
initial: -80,
|
|
408
|
+
minimum: -82,
|
|
409
|
+
},
|
|
410
|
+
});
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
With the default `zoom.ratio` and `zoom.unitSize` values, `-82` makes one millisecond roughly
|
|
414
|
+
200 px wide. The scale remains continuous below that value if you choose a lower minimum; the
|
|
415
|
+
smallest representable time and tick unit remains one millisecond. Custom ratio or unit-size
|
|
416
|
+
settings change the corresponding numeric zoom values.
|
|
417
|
+
|
|
418
|
+
Sub-day markers use an independent visual grid: major intervals change only when they have at
|
|
419
|
+
least `zoom.unitSize.minimumMajor` pixels (default `120`). A reduced set of significant minor
|
|
420
|
+
subdivisions appears only when it meets `zoom.unitSize.showMinorLabels` (default `48`), or the
|
|
421
|
+
larger `zoom.unitSize.minimum` value if customized. Every adaptive subdivision can therefore show
|
|
422
|
+
unitless labels as soon as it appears, while major labels remain readable.
|
|
423
|
+
|
|
424
|
+
Below day scale, article density uses fixed time regions. The first sub-day density level divides
|
|
425
|
+
each day into two half-day regions; every subsequent density transition divides every existing
|
|
426
|
+
region exactly in half, down to millisecond input resolution. Region boundaries remain attached to
|
|
427
|
+
their date and time while panning and between density transitions.
|
|
428
|
+
|
|
429
|
+
Navigation, `initialDate`, and viewport bounds accept either date-part objects, `Dmy` instances, or
|
|
430
|
+
timezone-free Histropedia date strings. The canonical grammar is
|
|
431
|
+
`year[-month[-day]][T| ]hour[:minute[:second[.SSS]]]`; the time part is optional, years may be
|
|
432
|
+
negative or longer than four digits, and fractional seconds contain one to three digits:
|
|
433
|
+
|
|
434
|
+
```js
|
|
435
|
+
timeline.setStartDate('2026-08-13T12:30:15.250', {
|
|
436
|
+
animation: { active: true, duration: 500 },
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
timeline.setCentreDate('-44-03-15 09:01');
|
|
440
|
+
timeline.fitDateRange('1000000000-06-15T12:00:00.000', '1000000000-06-15T12:00:00.001');
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
These strings are calendar positions, not JavaScript `Date` instants: timezone suffixes such as
|
|
444
|
+
`Z` or `+01:00` are intentionally unsupported. Omitted month/day values default to `1`; for
|
|
445
|
+
`fitDateRange`, a time-free year-only or month-only input represents that complete calendar
|
|
446
|
+
period.
|
|
447
|
+
|
|
448
|
+
### Card layouts
|
|
449
|
+
|
|
450
|
+
Two built-in layouts are registered: `portrait` and `landscape`. By default the timeline falls back to `article.defaultCardLayout: 'portrait'`, while ordered `article.cardLayoutBreakpoints` can override that fallback using the currently available vertical space for article cards.
|
|
451
|
+
|
|
452
|
+
```js
|
|
453
|
+
const timeline = new Timeline(container, {
|
|
454
|
+
article: {
|
|
455
|
+
distanceToBaseline: { value: 350 },
|
|
456
|
+
defaultCardLayout: 'portrait',
|
|
457
|
+
cardLayoutBreakpoints: [{ maxHeight: 220, layout: 'landscape' }],
|
|
458
|
+
},
|
|
459
|
+
});
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
Explicit `article.cardLayout` values still win, and lane defaults can set `lane.article.defaultCardLayout` as that lane's fallback layout when no breakpoint matches.
|
|
463
|
+
|
|
464
|
+
You can register custom layouts:
|
|
465
|
+
|
|
466
|
+
```js
|
|
467
|
+
import { Timeline } from 'histropediajs';
|
|
468
|
+
|
|
469
|
+
Timeline.registerCardLayout({
|
|
470
|
+
name: 'my-card',
|
|
471
|
+
draw(ctx) {
|
|
472
|
+
// draw using this.position, this.getCurrentStyle(), this.image, etc.
|
|
473
|
+
},
|
|
474
|
+
defaultStyle: {
|
|
475
|
+
/* optional style defaults */
|
|
476
|
+
},
|
|
477
|
+
defaultHoverStyle: {
|
|
478
|
+
/* optional */
|
|
479
|
+
},
|
|
480
|
+
defaultActiveStyle: {
|
|
481
|
+
/* optional */
|
|
482
|
+
},
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
const timeline = new Timeline(container, {
|
|
486
|
+
article: { defaultCardLayout: 'my-card' },
|
|
487
|
+
});
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
## Images and security
|
|
491
|
+
|
|
492
|
+
- Every article image is sanitized before load. By default the timeline calls `sanitizeImageUrl` (src/services/url-sanitizer.js), which trims the value, enforces the scheme allowlist (`http`, `https`, `data`, `blob`), and rejects non image `data:` payloads.
|
|
493
|
+
- Origins are unrestricted unless you supply `image.sanitizer.allowedOrigins`. Add host patterns (full origins, `*.example.com`, `.example.com`, bare hostnames) to enforce an allowlist, or provide a custom sanitizer.
|
|
494
|
+
- `blob:` and `data:` URLs skip origin checks but still require an allowed scheme. `data:` URLs must begin with `data:image/`.
|
|
495
|
+
- If you provide `image.customSanitizer`, it receives the raw URL and your `image.sanitizer` options object (including any custom fields you add). Return a trusted URL string to allow the load or `null` to block it; when `null` is returned the article keeps rendering without an image.
|
|
496
|
+
|
|
497
|
+
```js
|
|
498
|
+
const timeline = new Histropedia.Timeline(container, {
|
|
499
|
+
image: {
|
|
500
|
+
sanitizer: {
|
|
501
|
+
// Configure the built-in sanitizer
|
|
502
|
+
allowedSchemes: ['https', 'data'],
|
|
503
|
+
allowedOrigins: [
|
|
504
|
+
'https://static.example-cdn.com',
|
|
505
|
+
'*.imgix.net',
|
|
506
|
+
'.example.com',
|
|
507
|
+
'media.example.com',
|
|
508
|
+
],
|
|
509
|
+
},
|
|
510
|
+
// Optional custom sanitizer (takes precedence)
|
|
511
|
+
customSanitizer: (url, opts) => {
|
|
512
|
+
try {
|
|
513
|
+
const candidate = new URL(url, window.location.href);
|
|
514
|
+
const isHttps = candidate.protocol === 'https:';
|
|
515
|
+
const onCdn = candidate.hostname.endsWith('.example-cdn.com');
|
|
516
|
+
return isHttps && onCdn ? candidate.href : null;
|
|
517
|
+
} catch {
|
|
518
|
+
return null;
|
|
519
|
+
}
|
|
520
|
+
},
|
|
521
|
+
},
|
|
522
|
+
});
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
### Image loader configuration
|
|
526
|
+
|
|
527
|
+
The image loader queues work on demand, deduplicates concurrent requests, and evicts cached bitmaps when the byte budget is exceeded. Tune it via `options.image`:
|
|
528
|
+
|
|
529
|
+
- `maxCacheBytes` (default `64 * 1024 * 1024`) caps the decoded raster cache. Set `0` to disable caching or `Infinity` to remove the cap.
|
|
530
|
+
- `maxConcurrent` (default `6`) limits concurrent fetch/decode operations.
|
|
531
|
+
- `requireCORS` (default `false`) sets `crossOrigin = 'anonymous'` so the canvas stays untainted when your CDN returns the correct CORS headers.
|
|
532
|
+
- `decodeMode` selects the decode pipeline: 'auto', 'prefer-bitmap', 'bitmap', 'prefer-img', or 'img'.
|
|
533
|
+
|
|
534
|
+
See `src/services/url-sanitizer.js` and `src/services/image-loader.js` for reference implementations and additional behaviour such as shape cropping and cache management.
|
|
535
|
+
|
|
536
|
+
## Accessibility
|
|
537
|
+
|
|
538
|
+
- Pointer interactions support mouse, touch, and trackpads.
|
|
539
|
+
- Consider keyboard affordances and focus management in your host app; the canvas itself is not focusable by default.
|
|
540
|
+
|
|
541
|
+
## Examples and demo
|
|
542
|
+
|
|
543
|
+
A demo app with scenarios is included.
|
|
544
|
+
|
|
545
|
+
- Run the demo locally:
|
|
546
|
+
|
|
547
|
+
```bash
|
|
548
|
+
npm install
|
|
549
|
+
npm run dev
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
Then open the served URL (Vite dev server). Switch scenarios via the toolbar.
|
|
553
|
+
|
|
554
|
+
## Browser support / Build targets
|
|
555
|
+
|
|
556
|
+
### Build targets
|
|
557
|
+
|
|
558
|
+
| Build | File | Target | Notes |
|
|
559
|
+
| ----- | ----------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
560
|
+
| ESM | `histropedia.esm.js` | ES2020 | Published npm entrypoint for bundlers and other ESM-capable runtimes. Uses native `async/await`, optional chaining (`?.`), nullish coalescing (`??`). |
|
|
561
|
+
| UMD | `histropedia.umd.js` / `histropedia.umd.min.js` | ES2017 | For `<script>` tags, CDN usage, or self-hosted browser embeds. The minified UMD file is published for UNPKG/jsDelivr. This build is not a CommonJS `require()` entrypoint. |
|
|
562
|
+
|
|
563
|
+
### Web APIs used
|
|
564
|
+
|
|
565
|
+
The library uses several Web APIs that may not exist in all browsers. Most are feature-detected with automatic fallbacks; a few require polyfills if you support older environments.
|
|
566
|
+
|
|
567
|
+
#### Performance boosts (feature-detected)
|
|
568
|
+
|
|
569
|
+
These APIs improve performance when available. The timeline works correctly without them, but may use more main-thread time or be slightly less efficient:
|
|
570
|
+
|
|
571
|
+
| API | Used for | Without it |
|
|
572
|
+
| --------------------- | ---------------------------------- | --------------------------------------------------------------------------- |
|
|
573
|
+
| `createImageBitmap()` | Off-thread image decoding | Falls back to `HTMLImageElement` + canvas; images decode on the main thread |
|
|
574
|
+
| `OffscreenCanvas` | Off-screen image cropping/resizing | Falls back to regular `<canvas>`; slightly more GC pressure |
|
|
575
|
+
| `img.decode()` | Async decode before paint | Falls back to `onload`; may cause minor jank when large images appear |
|
|
576
|
+
| `performance.now()` | High-resolution cache timestamps | Falls back to `Date.now()`; millisecond precision instead of sub-ms |
|
|
577
|
+
|
|
578
|
+
#### Graceful degradation (feature-detected)
|
|
579
|
+
|
|
580
|
+
These APIs provide enhanced functionality when available. The timeline remains fully functional without them, with minor behavioural differences:
|
|
581
|
+
|
|
582
|
+
| API | Used for | Without it |
|
|
583
|
+
| --------------------------------------- | ------------------------------------------ | ------------------------------------------------------------------ |
|
|
584
|
+
| `AbortController` | Cancelling in-flight image fetches | Requests complete even if no longer needed; wastes some bandwidth |
|
|
585
|
+
| `document.fonts` (CSS Font Loading API) | Detecting when custom fonts finish loading | Text may briefly render in fallback font before redraw |
|
|
586
|
+
| Pointer Events | Unified mouse/touch/pen handling | Falls back to separate mouse + touch listeners; same end behaviour |
|
|
587
|
+
|
|
588
|
+
#### APIs that may need polyfills
|
|
589
|
+
|
|
590
|
+
These APIs are used directly without fallbacks. They're widely supported in modern browsers, but very old environments may need polyfills:
|
|
591
|
+
|
|
592
|
+
| API | Used for |
|
|
593
|
+
| ----------------------- | ---------------------------------------- |
|
|
594
|
+
| `fetch()` | Network image loading |
|
|
595
|
+
| `Promise` | Async operations throughout |
|
|
596
|
+
| `Map` / `Set` | Caching, deduplication, pointer tracking |
|
|
597
|
+
| `URL` constructor | Parsing and validating image URLs |
|
|
598
|
+
| `requestAnimationFrame` | Smooth animations |
|
|
599
|
+
|
|
600
|
+
## Development
|
|
601
|
+
|
|
602
|
+
See CONTRIBUTING.md for the build, test, and release workflow, including npm scripts, linting, and publishing guidance.
|
|
603
|
+
|
|
604
|
+
## TypeScript
|
|
605
|
+
|
|
606
|
+
TypeScript definitions are included in the package via `index.d.ts`. The types are automatically picked up by TypeScript-aware editors and bundlers.
|
|
607
|
+
|
|
608
|
+
## Resources
|
|
609
|
+
|
|
610
|
+
- Hosted documentation (guides, API reference, option matrix): https://js.histropedia.com/documentation
|
|
611
|
+
- Event payload reference: docs/events.md
|
|
612
|
+
- Contribution workflow: CONTRIBUTING.md
|
|
613
|
+
- Security policy: SECURITY.md
|
|
614
|
+
|
|
615
|
+
## License
|
|
616
|
+
|
|
617
|
+
This package is distributed under a custom HistropediaJS license. Please review the full terms at: [https://js.histropedia.com/licence](https://js.histropedia.com/licence).
|
|
618
|
+
|
|
619
|
+
For repository consumers, a `LICENSE` stub is included pointing to the hosted license text. Commercial use or redistribution may require additional permissions - contact us if unsure.
|