mirror of
https://git.vladimir.cc/vladimir/ewsdr.git
synced 2026-08-25 19:45:09 +00:00
fix web wheel: filter slides smoothly without passing through center
Track wheelActiveTs on each wheel tick; suppress server center_hz overwrites for 300ms after last wheel event so localCenter stays at the current VFO position instead of snapping back to screen center. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+3
-3
@@ -174,7 +174,7 @@ begin
|
||||
|
||||
'let cur={},vfoA=14200000,vfoB=14200000,activeVfo="A";' +
|
||||
'let localCenter=14200000,localSpan=192000;' + // локальные копии — обновляются мгновенно при действии пользователя
|
||||
'let dragging=false,dragX0=0,dragCen0=0,dragVfo0=0,dragMs=0;' +
|
||||
'let dragging=false,dragX0=0,dragCen0=0,dragVfo0=0,dragMs=0,wheelActiveTs=0;' +
|
||||
'let hoverX=-1,wTarget="",markerOn=false,markerX=0;' +
|
||||
'let specSm=[],wfAvg=[],wfHi=-50,wfLo=-120;' +
|
||||
'let audioCtx=null,audioT=0;' +
|
||||
@@ -409,7 +409,7 @@ begin
|
||||
'function applyState(msg){' +
|
||||
'Object.keys(msg).forEach(function(k){var pk=PEND_MAP[k];if(!pk||!isPending(pk))cur[k]=msg[k];});' +
|
||||
// Обновляем localCenter/localSpan из сервера только когда пользователь не тянет
|
||||
'if(!dragging){' +
|
||||
'if(!dragging&&Date.now()-wheelActiveTs>300){' +
|
||||
'if(msg.center_hz!=null)localCenter=msg.center_hz;' +
|
||||
'if(msg.span_hz!=null)localSpan=msg.span_hz||192000;' +
|
||||
'}' +
|
||||
@@ -494,7 +494,7 @@ begin
|
||||
'function sendActiveFreq(f){if(activeVfo==="A")ws2({cmd:"freq",hz:f});else ws2({cmd:"freq",hz:f});}' +
|
||||
'function doWheel(e){e.preventDefault();e.stopPropagation();audioKick();const dir=e.deltaY<0?1:-1,st=tuneStep(e),base=Math.floor(activeVfoHz()/st)*st;' +
|
||||
'const nf=cl(dir>0?base+st:(Math.round(activeVfoHz())===base?base-st:base),30000,60000000);' +
|
||||
'setActiveVfoHz(nf);localCenter=nf;' +
|
||||
'setActiveVfoHz(nf);wheelActiveTs=Date.now();' +
|
||||
'if(activeVfo==="A"){cur.vfo_a_hz=nf;}else{cur.vfo_b_hz=nf;}' +
|
||||
'renderVfos();pend("freq");ws2({cmd:"freq",hz:nf});}' +
|
||||
'function bindCv(cv){let wT=0;const wh=e=>{const n=performance.now();if(n-wT<20)return;wT=n;wTarget=cv.id;doWheel(e);};' +
|
||||
|
||||
Reference in New Issue
Block a user