Published
Edited
Aug 8, 2019
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function replayType() {
if (mutable animation_id !== null) cancelAnimationFrame(mutable animation_id)
let progress = 0;
let lookup = offsets.slice()
function step(timestamp) {
// probably a cleaner way to do this
if (lookup.length === 1) {
if (progress > lookup[0][1]) {
let splice = lookup.splice(0, 1)
mutable text = display(splice[0][0])
}
} else {
for (let i = 0; i < lookup.length; i++) {
let time = lookup[i][1]
if (time > progress) {
let end = i;
if (end > 0) {
let splice = lookup.splice(0, end)
let last = splice[splice.length - 1]
mutable text = display(last[0])
}
break;
}
}
}
if (lookup.length > 0) {
mutable animation_id = requestAnimationFrame(step);
}
progress += frame / milli * speed
}

mutable animation_id = requestAnimationFrame(step);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more