MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / animatedMove

Function animatedMove

source code/utils/computerUse/executor.ts:219–257  ·  view source on GitHub ↗

* Port of Cowork's `animateMouseMovement` + `animatedMove`. Ease-out-cubic at * 60fps; distance-proportional duration at 2000 px/sec, capped at 0.5s. When * the sub-gate is off (or distance < ~2 frames), falls through to * `moveAndSettle`. Called only from `drag` for the press→to motion — target

(
  input: Input,
  targetX: number,
  targetY: number,
  mouseAnimationEnabled: boolean,
)

Source from the content-addressed store, hash-verified

217 * intermediate positions (scrollbars, window resizes).
218 */
219async function animatedMove(
220 input: Input,
221 targetX: number,
222 targetY: number,
223 mouseAnimationEnabled: boolean,
224): Promise<void> {
225 if (!mouseAnimationEnabled) {
226 await moveAndSettle(input, targetX, targetY)
227 return
228 }
229 const start = await input.mouseLocation()
230 const deltaX = targetX - start.x
231 const deltaY = targetY - start.y
232 const distance = Math.hypot(deltaX, deltaY)
233 if (distance < 1) return
234 const durationSec = Math.min(distance / 2000, 0.5)
235 if (durationSec < 0.03) {
236 await moveAndSettle(input, targetX, targetY)
237 return
238 }
239 const frameRate = 60
240 const frameIntervalMs = 1000 / frameRate
241 const totalFrames = Math.floor(durationSec * frameRate)
242 for (let frame = 1; frame <= totalFrames; frame++) {
243 const t = frame / totalFrames
244 const eased = 1 - Math.pow(1 - t, 3)
245 await input.moveMouse(
246 Math.round(start.x + deltaX * eased),
247 Math.round(start.y + deltaY * eased),
248 false,
249 )
250 if (frame < totalFrames) {
251 await sleep(frameIntervalMs)
252 }
253 }
254 // Last frame has no trailing sleep — same HID round-trip before the
255 // caller's mouseButton reads NSEvent.mouseLocation.
256 await sleep(MOVE_SETTLE_MS)
257}
258
259// ── Factory ───────────────────────────────────────────────────────────────
260

Callers 1

dragFunction · 0.85

Calls 2

moveAndSettleFunction · 0.85
sleepFunction · 0.85

Tested by

no test coverage detected