Smooth zoom that follows the cursor: springs, a NaN and long moves
Short answer: to make a zoom follow the cursor without making anyone seasick, move the camera with a critically damped spring, a = ω²(target − x) − 2ωv, which settles as fast as it can without ringing. If you know the whole path in advance, run the spring forwards and then backwards so the camera starts to move a moment before the cursor does. When the spring is stiff for your step size (ω times dt above about 0.83 with the usual semi-implicit Euler step), use the exact solution instead, or it blows up. And on long moves, pull the zoom back before the cursor travels further than the view can hold.
All of that lives in Framok, my screen recorder for Windows, which adds the zooms after you record. Here's how the camera works, the NaN that parked the cursor in a corner, the half second the zoomed camera lost it, and what's next.
Why springs
A camera glued to the cursor shakes with every twitch of your hand. An easing curve needs to know where the move ends and how long it takes, and a cursor never tells you. A spring only needs a target: every step it accelerates towards wherever the target is now, and slows itself in proportion to its speed.
Tune the slowing down just right and you get critical damping: the system "returns to steady state as quickly as possible without oscillating" (Wikipedia). Less damping and the camera wobbles past the cursor and back, the seasick part.
Framok's spring step, as it is in the repo:
// Critically damped spring step.
function spring(x, v, target, omega, dt) {
const a = omega * omega * (target - x) - 2 * omega * v;
v += a * dt;
x += v * dt;
return [x, v];
}
omega is the stiffness, 2π over a response time (0.45 s to 1.35 s for the zoom, set by the editor's Smoothness slider). Everything that moves is worked out ahead of time into tracks sampled at 120 Hz, and the preview and the export read the same tracks.

Two clicks a second apart are one move
The first problem wasn't the spring at all. Two clicks a second or two apart made the camera zoom out and straight back in: the first zoom's hold ran out, the spring started the pull back, and the next click dragged it in again. It reads as a flinch.
0.4.2 joined them up (the code on 8 Sep in c02e8f5, the changelog in 7a0cc95): a click within 1.5 s of the end of a zoom joins that zoom instead of starting a new one. It's a slider now, Join nearby zooms, from 0 to 4 seconds.
if (last && c[0] <= last.end + merge) { last.end = c[0] + settings.zoomHold; last.clicks.push(c); }
else segs.push({ start: Math.max(0, c[0] - lead), end: c[0] + settings.zoomHold, level: settings.zoomLevel, clicks: [c], typed: false });
The segments are built over the whole recording before a frame is drawn, so the merge is retroactive and the camera never starts a pull back it would have to reverse.
A spring that looks ahead
Working ahead of time has another payoff. A live spring always arrives late. With the whole track in hand, Framok runs the spring forwards over it and then backwards over the result:
export function smoothTrack(arr, omega, dt) {
const n = arr.length;
if (n < 2) return Float64Array.from(arr);
const out = new Float64Array(n), k = omega * omega, d = 2 * omega;
let x = arr[0], v = 0;
for (let i = 0; i < n; i++) { v += (k * (arr[i] - x) - d * v) * dt; x += v * dt; out[i] = x; }
x = out[n - 1]; v = 0;
for (let i = n - 1; i >= 0; i--) { v += (k * (out[i] - x) - d * v) * dt; x += v * dt; out[i] = x; }
return out;
}
The forward pass lags behind, the backward pass lags the other way, and together they cancel. The camera starts to drift towards a click a moment before you make it.
The NaN in the top left corner
Making ads for Framok on 24 Sep turned up two bugs. The first: with the cursor's Smoothing slider below about 15 percent, the exported cursor got stuck in the top left corner of the video.
The cursor glides on a spring too, with its stiffness set by the slider:
return (2 * Math.PI) / (0.04 + Math.min(1, s) * 0.16);
At 0 that's ω of about 157 per second, and at 120 Hz ω times dt comes to 1.31. That number is the whole story.
The step above is semi-implicit Euler: update the speed, then move by the new speed. Write ω times dt as a. Each step multiplies the cursor's error and speed by a fixed 2 by 2 matrix whose determinant is 1 − 2a and whose trace is 2 − 2a − a². That only stays bounded while a is under 2√2 − 2, about 0.83. Above 0.5 the determinant goes negative, so part of the error flips sign every step: the cursor rings. Above 0.83 it grows every step until the numbers overflow to infinity, and infinity minus infinity is NaN. The cursor track filled with NaN, and the export drew it in the top left corner.
Solve 2π / (120 × (0.04 + 0.16s)) < 0.83 and s has to be over about 0.14. The slider moves in 5 percent steps, so 0, 5 and 10 percent broke. Run the old step on a single 500 px jump and it goes non finite after 5.45 s at 0, 8.53 s at 5 percent and 18.1 s at 10 percent of a recording, which is why a short test take could look fine.
The exact spring
The fix, built as 0.7.7 and shipped in 0.7.11 on 27 Sep, was to stop stepping the cursor's spring and solve it. A critically damped spring has a closed form: with e the distance from the target and c = v + ωe, after a time dt the distance is (e + c·dt) times e^(−ω·dt). It's the same formula as critical_spring_damper_exact in the Spring-It-On roll call of springs for game developers (The Orange Duck). In Framok:
export function springExact(x, v, target, omega, dt) {
const e = x - target, c = v + omega * e, k = Math.exp(-omega * dt);
return [target + (e + c * dt) * k, (v - omega * c * dt) * k];
}
It's exact for any ω and any step, so there's nothing left to go unstable, and it costs one Math.exp per step. A critically damped spring can pass its target at most once, when it starts with speed, and never rings.
Smoothing at 0 now means no glide at all, so the cursor sits exactly on the recorded samples, and a value that's missing or not a number takes the default.
The camera's springs keep the cheap step: they're much softer, and the stiffest sits at about 0.38 for ω times dt.
A test now sweeps every slider stop on a take that flings the cursor into the corners: every sample finite, never past the screen's edge, within a pixel of each spot the pointer rests on, and never turning back more often than the real pointer did.
Long moves: the half second the cursor left the frame
The second bug from those ads was in the 16:9 camera. In wide frames (Fit) the zoom and the pan are springs that ease after the cursor, and on one take at zoom 2.1 a long fast move across the screen outran them. The cursor was out of frame from 3.71 to 4.17 s, and again later in the same take.
Stiffer springs would bring the seasickness back. The fix, in the same release, borrows the rule the tall video camera already used for travel: look at where the cursor goes from 200 ms back to 450 ms ahead, and if that path won't fit in 70 percent of the view, lower the zoom.
const cap = Math.max(1, Math.min(cw / Math.max(1e-6, (x1 - x0) / TRAVEL_FIT * 1.02), ch / Math.max(1e-6, (y1 - y0) / TRAVEL_FIT * 1.02)));
if (cap < s0) D[i] = Math.log(cap / s0);
The pull back is worked out in log zoom, widened a little in time and smoothed with the same forwards and backwards spring, so the camera starts easing out before the cursor sets off and eases back in once it lands. Then the path is pulled in wherever the cursor would be less than 15 percent in from an edge.
What keeps it calm: only the corrections are smoothed, never the camera itself, so a camera that already holds the cursor well inside is left exactly as it was. The smoothed passes aim 4 percent further in than the margin, so the final hard pass that guarantees the 15 percent has next to nothing left to clip.
The tests run 13 takes at both 16:9 and 4:3 and check that the cursor never breaks its margin, the zooms still reach their level, the camera's biggest step between samples stays under half the cursor's, the zoom never changes faster than 2x in 220 ms, and the path never kinks by more than 1.2 percent of the view. 0.7.7 passed 182 of 182.
Next: keeping the clicked button whole
The guard keeps the cursor in frame, but it doesn't know about the thing you clicked. On 16 Nov I wrote the next step for the zoomed 16:9 camera (ade5118): when the clicked element fits inside the zoomed view, the camera eases sideways so all of it is in frame around the press.
Hard limits on the camera gave kinks of 2 to 3 percent of the view and 50 px steps, so it's a soft pull, smoothed by the guard's own spread, and the cursor's margin always wins. Fill, Stack and unzoomed tracks came out bit identical to before over 20 random takes each, and the suite is at 225 of 225 with 4 new tests. It isn't in a release yet.
What I'd tell anyone doing this
- Use critical damping for anything that follows a person. Anything less wobbles.
- Check ω times dt. With a fixed step, semi-implicit Euler is stable below about 0.83 and rings above 0.5. If a setting can push past that, solve the spring exactly.
- Test every value a slider can reach, not the default. My bug lived in the three stops nobody tries.
- If you can see the future, use it. A spring run forwards then backwards has no lag.
- Correct the camera only where it's wrong, and smooth the correction rather than the path.
Zoom in Framok today
Framok places a zoom on every click before the editor opens. You can drag any zoom block, add your own, and set how far it zooms, how lazy the camera is, how far apart clicks can be and still join, and how much the cursor glides, all after recording. For the plain how to, there's how to zoom in and out on a screen recording on Windows, and the Screen Studio look on Windows covers the rest of the polish.
Where Framok doesn't help
- Only recordings made in Framok. The camera needs the cursor and click data it saves while recording, so it can't zoom a video from another recorder.
- No live zoom. The zooms are worked out after you record, so they won't help a live stream. For that, the OBS zoom to mouse guide covers the script and its OBS 32 fix.
- Windows only. Windows 10 or later, 64 bit. A Mac version is coming, with an email waitlist on framok.com.
- The download isn't code signed yet, so SmartScreen warns the first time. Click More info, then Run anyway.
Framok is $29 once for the life of the product, or $5 a month and cancel any time. Both cover 2 of your own PCs, and the download is free for 7 days with every feature, no card and no account.
Anyone else running springs at a fixed step? I'd like to know what ω times dt yours sit at.
Sources
- Wikipedia, Harmonic oscillator, on critical damping
- The Orange Duck, Spring-It-On: The Game Developer's Spring-Roll-Call, for the exact critically damped spring
- Framok's changelog (0.4.2 and 0.7.11, which covers 0.7.6 to 0.7.11), commits c02e8f5 and 7a0cc95 (8 Sep 2026), fbabd7d (25 Sep 2026) and ade5118 (16 Nov 2026), and the camera code and tests in the recorder repo
- My build notes from 24 Sep and 16 Nov 2026