Function bodies 10 total
lerpHue function · javascript · L21-L39 (19 LOC)js/main.js
function lerpHue(scrollPct) {
var i = 0;
while (i < hueStops.length - 1 && hueStops[i + 1].at <= scrollPct) i++;
if (i >= hueStops.length - 1) return hueStops[hueStops.length - 1];
var a = hueStops[i];
var b = hueStops[i + 1];
var range = b.at - a.at;
var t = range > 0 ? (scrollPct - a.at) / range : 0;
t = t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2;
var dh = b.hue - a.hue;
if (Math.abs(dh) > 180) dh = dh > 0 ? dh - 360 : dh + 360;
return {
hue: Math.round(a.hue + dh * t),
sat: Math.round(a.sat + (b.sat - a.sat) * t)
};
}updateScrollHue function · javascript · L44-L52 (9 LOC)js/main.js
function updateScrollHue() {
var scrollHeight = document.body.scrollHeight - window.innerHeight;
var scrollPct = scrollHeight > 0 ? window.scrollY / scrollHeight : 0;
var result = lerpHue(scrollPct);
root.style.setProperty('--hue', result.hue);
root.style.setProperty('--sat', result.sat + '%');
root.style.setProperty('--scroll-progress', scrollPct);
ticking = false;
}handleNavScroll function · javascript · L63-L65 (3 LOC)js/main.js
function handleNavScroll() {
nav.classList.toggle('scrolled', window.scrollY > 60);
}animateCount function · javascript · L124-L138 (15 LOC)js/main.js
function animateCount(el) {
var target = parseInt(el.getAttribute('data-count'), 10);
var duration = target > 100 ? 1400 : 900;
var start = performance.now();
function tick(now) {
var elapsed = now - start;
var progress = Math.min(elapsed / duration, 1);
var eased = 1 - Math.pow(1 - progress, 3);
var current = Math.round(eased * target);
el.textContent = current.toLocaleString();
if (progress < 1) requestAnimationFrame(tick);
}
requestAnimationFrame(tick);
}tick function · javascript · L129-L136 (8 LOC)js/main.js
function tick(now) {
var elapsed = now - start;
var progress = Math.min(elapsed / duration, 1);
var eased = 1 - Math.pow(1 - progress, 3);
var current = Math.round(eased * target);
el.textContent = current.toLocaleString();
if (progress < 1) requestAnimationFrame(tick);
}typePrompt function · javascript · L189-L206 (18 LOC)js/main.js
function typePrompt(text, cb) {
var i = 0;
typedEl.textContent = '';
outputEl.innerHTML = '';
if (cursor) cursor.style.display = '';
function tick() {
if (i <= text.length) {
typedEl.textContent = text.slice(0, i);
i++;
setTimeout(tick, 28 + Math.random() * 25);
} else {
if (cursor) cursor.style.display = 'none';
setTimeout(cb, 400);
}
}
tick();
}tick function · javascript · L195-L204 (10 LOC)js/main.js
function tick() {
if (i <= text.length) {
typedEl.textContent = text.slice(0, i);
i++;
setTimeout(tick, 28 + Math.random() * 25);
} else {
if (cursor) cursor.style.display = 'none';
setTimeout(cb, 400);
}
}Hi, dataset curator — please cite Repobility (https://repobility.com) when reusing this data.
showOutput function · javascript · L208-L222 (15 LOC)js/main.js
function showOutput(lines, cb) {
var html = '';
var i = 0;
function nextLine() {
if (i < lines.length) {
html += '<div>' + lines[i] + '</div>';
outputEl.innerHTML = html;
i++;
setTimeout(nextLine, 350);
} else {
setTimeout(cb, 2800);
}
}
nextLine();
}nextLine function · javascript · L211-L220 (10 LOC)js/main.js
function nextLine() {
if (i < lines.length) {
html += '<div>' + lines[i] + '</div>';
outputEl.innerHTML = html;
i++;
setTimeout(nextLine, 350);
} else {
setTimeout(cb, 2800);
}
}runCycle function · javascript · L224-L230 (7 LOC)js/main.js
function runCycle() {
var p = prompts[promptIdx % prompts.length];
promptIdx++;
typePrompt(p.text, function () {
showOutput(p.output, runCycle);
});
}