Vote page: auto zoom looks closer at the middle when no ring shows up at all (back rows)
This commit is contained in:
+9
-2
@@ -182,12 +182,14 @@ function makeScanner(video, onToken, onOther) {
|
|||||||
// ~40 % of the frame, never so far that it would leave the frame. a code filling the frame zooms back out,
|
// ~40 % of the frame, never so far that it would leave the frame. a code filling the frame zooms back out,
|
||||||
// and losing it for a while goes back to the widest view
|
// and losing it for a while goes back to the widest view
|
||||||
function newZoomState(base, max) {
|
function newZoomState(base, max) {
|
||||||
return { base, max, now: base, auto: true, lastRead: 0, lastSeen: 0, lastMove: 0 };
|
const t = performance.now();
|
||||||
|
return { base, max, now: base, auto: true, lastRead: 0, lastSeen: t, lastMove: t };
|
||||||
}
|
}
|
||||||
|
|
||||||
function zoomPlan(zs, d, now) {
|
function zoomPlan(zs, d, now) {
|
||||||
if (d.token) zs.lastRead = now;
|
if (d.token) zs.lastRead = now;
|
||||||
const w = d.where, seen = !!w && (d.score ?? 0) >= 0.55;
|
// a zoom too many costs nothing, so a weak sync ring is enough to steer on
|
||||||
|
const w = d.where, seen = !!w && (d.score ?? 0) >= 0.4;
|
||||||
if (seen) zs.lastSeen = now;
|
if (seen) zs.lastSeen = now;
|
||||||
if (now - zs.lastMove < 900) return null;
|
if (now - zs.lastMove < 900) return null;
|
||||||
let z = null;
|
let z = null;
|
||||||
@@ -201,6 +203,11 @@ function zoomPlan(zs, d, now) {
|
|||||||
} else if (!seen && now - zs.lastSeen > 2500 && zs.now > zs.base) {
|
} else if (!seen && now - zs.lastSeen > 2500 && zs.now > zs.base) {
|
||||||
z = zs.base;
|
z = zs.base;
|
||||||
zs.lastSeen = now;
|
zs.lastSeen = now;
|
||||||
|
} else if (!seen && zs.now === zs.base && now - zs.lastSeen > 1500 && now - zs.lastMove > 1500) {
|
||||||
|
// from the back rows the ring is too small to be found at all: look closer where the person aims, the
|
||||||
|
// middle, and fall back to wide again (branch above) when nothing shows up there either
|
||||||
|
z = Math.min(zs.max, zs.base * 2);
|
||||||
|
zs.lastSeen = now;
|
||||||
}
|
}
|
||||||
if (z != null) zs.lastMove = now;
|
if (z != null) zs.lastMove = now;
|
||||||
return z;
|
return z;
|
||||||
|
|||||||
Reference in New Issue
Block a user