mirror of
https://github.com/Louis-CFM/coucou.git
synced 2026-12-07 07:32:35 +09:00
The drop was three beats — morph, gulp, bar — where macOS has a timeline of fifteen, drawn in a canvas of its own. This ports that canvas. - src/upload/sequence.ts is UploadSequenceEngine.swift: the phase constants, the four easings, springs integrated at 240 Hz, the lock onto a slow cursor, the squeeze keyframes and the progress curve. Pure arithmetic, no DOM. - src/upload/canvas.ts is UploadCanvasView.swift: card, marching dashed border, the green glow that rises with progress, the bar and its blurred trail, the choose card, Mochi's superellipse body with its three eye shapes, and the file cut into 28 strips that funnel into the mouth. So the sequence now reads: the box slides under the cursor and locks on, the mouth opens, the file is sucked in over 0.30 s, the mouth shuts, Mochi chews, shrinks to a 14 px bead riding the head of the bar, hops at 100 %, then grows back and walks left as the choose card fades in. The island hides its own Mochi while this runs — two would overlap — and the header stays overlaid on top, as on macOS. Leaving the drop views, or shutting the island, stops the engine: left running it would keep the frame loop awake and cost CPU with nothing on screen. Two deliberate differences. macOS insets the real file icon from NSWorkspace into the sheet; the webview cannot reach it, so the generic sheet is drawn, which is already the Swift's own fallback. And the secondary button stays "Cancel" rather than "Send by email", which the Windows v1 does not have. dev/upload-preview.html replays the whole thing on a loop under `npm run dev`, since the alternative is dragging a file from Explorer for every tweak. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
// Dev harness: plays the whole drop sequence in a plain browser so the
|
|
// choreography can be watched without an OLE drag. Not part of the app bundle.
|
|
|
|
import { UploadCanvas } from "../src/upload/canvas";
|
|
import { UploadSeq } from "../src/upload/sequence";
|
|
import { State } from "../src/core/state";
|
|
|
|
State.droppedFile = { name: "rapport-q3.pdf", path: "C:/tmp/rapport-q3.pdf" };
|
|
|
|
const stage = document.getElementById("stage")!;
|
|
const clock = document.getElementById("clock")!;
|
|
|
|
const canvas = new UploadCanvas({
|
|
ask: () => (clock.textContent = "ASK clicked"),
|
|
cancel: () => (clock.textContent = "CANCEL clicked"),
|
|
});
|
|
canvas.el.classList.add("on");
|
|
canvas.el.style.position = "absolute";
|
|
canvas.el.style.left = "0";
|
|
stage.append(canvas.el);
|
|
|
|
// The cursor walks in from the right, settles over the box, then drops.
|
|
// The whole thing restarts every 12 s so it can be watched (and screenshotted)
|
|
// without reloading the page.
|
|
const CYCLE = 12;
|
|
let start = performance.now();
|
|
let dropped = false;
|
|
UploadSeq.enterZone(520, 96);
|
|
|
|
function loop(now: number) {
|
|
let t = (now - start) / 1000;
|
|
if (t >= CYCLE) {
|
|
start = now;
|
|
t = 0;
|
|
dropped = false;
|
|
UploadSeq.enterZone(520, 96);
|
|
}
|
|
if (!dropped) {
|
|
const x = 520 - Math.min(1, t / 0.9) * 260;
|
|
UploadSeq.updateCursor(x, 96);
|
|
if (t >= 1.2) {
|
|
dropped = true;
|
|
UploadSeq.performDrop(2.4);
|
|
}
|
|
}
|
|
canvas.draw(UploadSeq.frame(), now / 1000);
|
|
clock.textContent = `t = ${t.toFixed(2)} s${dropped ? " (dropped)" : " (dragging)"}`;
|
|
requestAnimationFrame(loop);
|
|
}
|
|
requestAnimationFrame(loop);
|