fix(zoom): hold connected zoom before handoff

This commit is contained in:
webadderall
2026-06-02 20:23:58 +10:00
parent 05fdfa4393
commit 8f3bbd5f0a
2 changed files with 13 additions and 3 deletions
@@ -400,7 +400,7 @@ describe("findDominantRegion", () => {
const result = findDominantRegion(regions, 3100, { connectZooms: true });
expect(result.transition).toBeNull();
expect(result.region?.id).toBe("a");
expect(result.strength).toBeGreaterThan(0);
expect(result.strength).toBe(1);
});
it("keeps the incoming region at full strength after a connected handoff", () => {
@@ -124,8 +124,18 @@ function getActiveRegion(
const activeRegions = regions
.map((region) => {
const outgoingPair = connectedPairs.find((pair) => pair.currentRegion.id === region.id);
if (outgoingPair && timeMs >= outgoingPair.transitionStart) {
return { region, strength: 0 };
if (outgoingPair) {
if (timeMs >= outgoingPair.transitionStart) {
return { region, strength: 0 };
}
const zoomOutStart =
outgoingPair.currentRegion.endMs -
ZOOM_OUT_EARLY_START_MS +
ZOOM_ANIMATION_LEAD_MS;
if (timeMs >= zoomOutStart) {
return { region, strength: 1 };
}
}
const incomingPair = connectedPairs.find((pair) => pair.nextRegion.id === region.id);