fix: remove alert(), fix waveform zoom, add waveform scroll (wheel + ctrl+wheel)

This commit is contained in:
Jose Luis Montañes
2026-03-19 22:08:26 +01:00
parent d5de328898
commit 7c58174f5f
3 changed files with 22 additions and 5 deletions

View File

@@ -214,12 +214,26 @@ export function initEvents() {
document.getElementById('wave-step').addEventListener('click', manualStep);
document.getElementById('wave-zoom-in').addEventListener('click', () => {
state.waveZoom = Math.min(60, state.waveZoom + 5);
state.waveZoom = Math.min(100, state.waveZoom + 5);
});
document.getElementById('wave-zoom-out').addEventListener('click', () => {
state.waveZoom = Math.max(5, state.waveZoom - 5);
state.waveZoom = Math.max(2, state.waveZoom - 5);
});
// Scroll waveform with mouse wheel
document.getElementById('wave-canvas').addEventListener('wheel', e => {
e.preventDefault();
if (e.ctrlKey || e.metaKey) {
// Ctrl+wheel = zoom waveform
const delta = e.deltaY > 0 ? -3 : 3;
state.waveZoom = Math.max(2, Math.min(100, state.waveZoom + delta));
} else {
// Wheel = scroll waveform horizontally
const scrollDelta = e.deltaY > 0 ? 3 : -3;
state.waveScroll = Math.max(0, state.waveScroll + scrollDelta);
}
}, { passive: false });
// ==================== SIMULATION CONTROLS ====================
document.getElementById('sim-run-btn').addEventListener('click', () => {
if (state.simRunning) stopSim(); else startSim();