Smooth phone page swipes
All checks were successful
Verify and publish Calio container / build-and-push (push) Successful in 28s
All checks were successful
Verify and publish Calio container / build-and-push (push) Successful in 28s
- Keep the page rail on its own compositor layer for the whole session instead of promoting it at every drag start - Write the drag transform directly in touchmove rather than a later rAF - Carry the release velocity into the settle animation (160-340ms) so flicks neither brake nor lurch; covered by a unit test - Render the page change as a transition so it cannot delay the settle - Pause bubble physics and canvas drawing while the pager is moving Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c3b9376508
commit
bb0bc430aa
6 changed files with 103 additions and 40 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { swipeStep } from "../shared/navigation.js";
|
||||
import { settleDuration, swipeStep } from "../shared/navigation.js";
|
||||
|
||||
test("phone swipes accept deliberate travel and short fast flicks in both directions", () => {
|
||||
assert.equal(swipeStep(-100, 8, 500, 393), 1);
|
||||
|
|
@ -14,3 +14,17 @@ test("scrolling, diagonal travel, slow small movements and jitter never switch t
|
|||
assert.equal(swipeStep(40, 2, 500, 393), 0);
|
||||
assert.equal(swipeStep(8, 0, 5, 393), 0);
|
||||
});
|
||||
test("a released swipe settles at the finger's speed, within natural bounds", () => {
|
||||
// Tab taps and slow releases use a distance-based duration.
|
||||
assert.equal(settleDuration(-393, 393), 340);
|
||||
assert.equal(settleDuration(-60, 393), 220);
|
||||
// A fast flick toward the destination shortens the settle so it starts at
|
||||
// the release velocity: 3.2 * 200px / 4px/ms = 160ms.
|
||||
assert.equal(settleDuration(-200, 393, -4), 160);
|
||||
// A gentle release never stretches the settle beyond the base duration.
|
||||
assert.equal(settleDuration(-250, 393, -2), 220);
|
||||
// Momentum away from the destination (a cancelled swipe) is ignored.
|
||||
assert.equal(settleDuration(150, 393, -3), Math.max(220, 340 * (150 / 393)));
|
||||
// Extremely fast flicks are clamped so the settle stays visible.
|
||||
assert.equal(settleDuration(-300, 393, -20), 160);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue