From 0e738e1967bfdbf7b6b0dd33a871b1c6dff1960c Mon Sep 17 00:00:00 2001 From: Uladzimir Karpenka Date: Sat, 9 May 2026 15:12:52 +0300 Subject: [PATCH] web: fix filter passband position on click and VFO wheel tuning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Click on spectrum/waterfall no longer sets localCenter immediately. The filter passband now appears exactly at the clicked pixel instead of jumping to screen center. Server's center_hz (arrives ~200ms later) naturally re-centers the display once fresh spectrum data is ready. VFO display wheel (vDispA/vDispB) now updates localCenter when tuning the active VFO. Previously localCenter lagged behind, causing applyState to teleport the filter back to center every 200ms (the "passes through center" oscillation). Spectrum canvas wheel (doWheel) is unchanged: user expects the spectrum to scroll when wheel-scrolling over it, filter stays at center — correct. Co-Authored-By: Claude Sonnet 4.6 --- WebPageHtml.pas | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/WebPageHtml.pas b/WebPageHtml.pas index af6416a..ab4208e 100644 --- a/WebPageHtml.pas +++ b/WebPageHtml.pas @@ -313,9 +313,9 @@ begin 'const nf=cl(f,30000,60000000);setHz(nf);renderVfos();onSend(nf);' + '});}' + 'bindVfo("vDispA",()=>vfoA,v=>{vfoA=v;},()=>stA,v=>{stA=v;},()=>stAmem,v=>{stAmem=v;},' + - 'function(nf){renderVfos();pend("freq");if(activeVfo==="A")ws2({cmd:"freq",hz:nf});else ws2({cmd:"freq_b",hz:nf});});' + + 'function(nf){renderVfos();pend("freq");if(activeVfo==="A"){localCenter=nf;ws2({cmd:"freq",hz:nf});}else ws2({cmd:"freq_b",hz:nf});});' + 'bindVfo("vDispB",()=>vfoB,v=>{vfoB=v;},()=>stB,v=>{stB=v;},()=>stBmem,v=>{stBmem=v;},' + - 'function(nf){renderVfos();pend("freq");if(activeVfo==="B")ws2({cmd:"freq",hz:nf});else ws2({cmd:"freq_b",hz:nf});});' + + 'function(nf){renderVfos();pend("freq");if(activeVfo==="B"){localCenter=nf;ws2({cmd:"freq",hz:nf});}else ws2({cmd:"freq_b",hz:nf});});' + 'function selVfo(w){' + 'activeVfo=w;' + @@ -530,9 +530,10 @@ begin 'cv.style.cursor="";' + 'if(e.button===2)return;' + 'if(dragging&&Math.abs(e.offsetX-dragX0)<4){' + - // клик — настраиваем на кликнутую частоту мгновенно + // клик — не трогаем localCenter: фильтр встаёт точно туда куда кликнули. + // Спектр остаётся на месте, сервер пришлёт center_hz через ~200ms и всё перецентрируется. 'const nf=cl(Math.round(xToHz(e.offsetX,cv.clientWidth)/100)*100,30000,60000000);' + - 'setActiveVfoHz(nf);localCenter=nf;' + + 'setActiveVfoHz(nf);' + 'if(activeVfo==="A")cur.vfo_a_hz=nf;else cur.vfo_b_hz=nf;' + 'renderVfos();pend("freq");ws2({cmd:"freq",hz:nf});' + '}' +