From 08188527ce291ccac76a9448593096b524f4fc1a Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Fri, 17 Jun 2022 19:42:40 +0200 Subject: [PATCH] high-res scroll events for the waterfall zoom --- htdocs/openwebrx.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index 14bb039..816478e 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -614,10 +614,25 @@ function get_relative_x(evt) { return relativeX - zoom_offset_px; } +var wheel_delta_remainder = 0; + function canvas_mousewheel(evt) { + var dir = (evt.deltaY / Math.abs(evt.deltaY)) > 0; + // deltaMode 0 means pixels instead of lines + if ('deltaMode' in evt && evt.deltaMode === 0) { + wheel_delta_remainder += evt.deltaY / 50; + console.info(wheel_delta_remainder); + if (wheel_delta_remainder >= 1) { + dir = true; + wheel_delta_remainder -= 1; + } else if (wheel_delta_remainder < 0) { + dir = false; + wheel_delta_remainder += 1; + } else return; + wheel_delta_remainder %= 1; + } if (!waterfall_setup_done) return; var relativeX = get_relative_x(evt); - var dir = (evt.deltaY / Math.abs(evt.deltaY)) > 0; zoom_step(dir, relativeX, zoom_center_where_calc(evt.pageX)); evt.preventDefault(); }