File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff 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 ) ) ;
You can’t perform that action at this time.
0 commit comments