Skip to content

Commit da1f719

Browse files
authored
Update primitive-vco.html
addressed slow page issue
1 parent 97b81ab commit da1f719

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

primers/primitive-vco.html

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,26 @@ <h2>Philosophical Footnote</h2>
9898
freqDisplay.textContent = freq;
9999

100100
const baseY = 150;
101-
const peakY = baseY - voltage * 10;
102-
const path = `M10 ${baseY} L50 ${peakY} L90 ${baseY} L130 ${peakY} L170 ${baseY}`;
103-
wave.setAttribute('d', path);
101+
const peakY = 100;
102+
const spacing = Math.max(10, 40 - voltage * 2); // Clamp spacing
103+
104+
const path = `
105+
M10 ${baseY}
106+
L${10 + spacing} ${peakY}
107+
L${10 + spacing * 2} ${baseY}
108+
L${10 + spacing * 3} ${peakY}
109+
L${10 + spacing * 4} ${baseY}
110+
`;
111+
wave.setAttribute('d', path.trim());
104112
}
105113

114+
let debounceTimer;
106115
slider.addEventListener('input', () => {
107-
const voltage = parseFloat(slider.value);
108-
updateWaveform(voltage);
116+
clearTimeout(debounceTimer);
117+
debounceTimer = setTimeout(() => {
118+
const voltage = parseFloat(slider.value);
119+
updateWaveform(voltage);
120+
}, 50);
109121
});
110122

111123
updateWaveform(parseFloat(slider.value));

0 commit comments

Comments
 (0)