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>
30 lines
1.5 KiB
JavaScript
30 lines
1.5 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
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);
|
|
assert.equal(swipeStep(100, -8, 500, 393), -1);
|
|
assert.equal(swipeStep(-40, 2, 65, 393), 1);
|
|
assert.equal(swipeStep(60, 0, 500, 320), -1);
|
|
});
|
|
test("scrolling, diagonal travel, slow small movements and jitter never switch tabs", () => {
|
|
assert.equal(swipeStep(12, 150, 250, 393), 0);
|
|
assert.equal(swipeStep(100, 100, 150, 393), 0);
|
|
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);
|
|
});
|