Repository navigation
Conversation
resolveDetent (motion/resolveDetent.ts, internal) is the motion foundation's release policy on selectSnapPoint: a slow release lands on the detent nearest where it was let go or projects to, a flick at least on the next detent in its direction, a release moving back toward its start cancels to it, and an optional step limit keeps it within N detents of where it started. - BottomSheet's resolveSheetRelease calls it with the sheet's UIKit thresholds instead of its own projection, flick and cancel code (moved from here unchanged; its release tests are the oracle). - selectPage moves to motion/selectPage.ts and calls it (one page per release, the paging rate as seconds of projection, no flick). - The interactive driver's header points release rules at it. Not exported from the package or any barrel; a test locks that. Co-authored-by: Christopher Chedeau <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
|
There was a problem hiding this comment.
Requesting changes for scope only. Against main, this pull request carries the whole unlanded #8386 stack (213 files, 42,582 changed lines), while the release-policy change itself is 10 files and 608 lines. Please land #8386 and its ancestors and rebase, or point the base at #8386's branch, so that the diff is this one commit; on its own, the commit reads as behavior-preserving, with the sheet's and the pager's landings unchanged and the existing release tests passing as they are. One small follow-up: the new guidance in packages/core/src/motion/interactive.ts says every release rule picks its rest position with resolveDetent, but the sheet's mouse path still uses resolveSettleOffset, so please scope that comment to the finger path.
[Automated review]
| * A release rule that picks one of a set of rest positions picks it with | ||
| * `resolveDetent` (resolveDetent.ts), the motion foundation's release | ||
| * policy, rather than with its own nearest/flick logic. |
There was a problem hiding this comment.
This says every release rule that picks among rest positions uses resolveDetent, but the sheet's own rule still picks a mouse release's detent with resolveSettleOffset (sheetRelease.ts:357-366 calls resolveDefaultRelease, which uses snapOffsets.ts:227-246). Could this be scoped to the finger path, or name the mouse path as the exception, so the next author doesn't read resolveSettleOffset as a violation?
The interactive driver's header said every release rule picks its rest position with resolveDetent, but the sheet's mouse path still settles with resolveSettleOffset. It now says a finger path's release rule does, and a mouse path may keep its own rule.
Platform glossary names, aligned to the merged records: the release policy is resolveSnapPoint (motion/resolveSnapPoint.ts) over the selectSnapPoint primitive, its inputs are snap points, and the flick input is flickThreshold. The back-out cancel stays an input, not an option: a release moving back toward a given start always cancels to it (spec:AST-094 FR37). No behavior change; the release tests pass unchanged.
There was a problem hiding this comment.
Requesting changes for scope only: against main, this pull request still carries the whole unlanded #8386 stack (213 files, 42,583 authored lines), while the release-policy change itself is 10 files and 612 lines. Please land #8386 and its ancestors and rebase, or base this pull request on a branch in this repository that holds #8386's head (#8386's own branch is on a fork, so it can't be picked as the base directly), so that the diff is just this change and CI can run on it. On its own, the change reads as behavior-preserving: the sheet's and the pager's landings follow from the same algorithm and thresholds, and the earlier note about the interactive.ts guidance is addressed.
[Automated review]
There was a problem hiding this comment.
This looks ready: resolveSnapPoint reproduces the sheet's and the pager's landings exactly, and the change stays within the current touch-presentation and release-velocity specs. Because the base is stack/8386, the CI and Lint workflows haven't run on it yet, so please make sure they pass once it targets main. Two optional test tweaks are noted inline: the tolerance case releases past the snap point, so it passes without tolerance, and the barrel loop finds no index file in motion/.
[Automated review]
| expect( | ||
| resolveSnapPoint({ | ||
| points: [0, 300, 640], | ||
| position: 300.5, |
There was a problem hiding this comment.
Non-blocking: at 300.5 the release is already past the 300 snap point, so the flick lands on 640 with or without tolerance, and this case still passes when the tolerance is removed. A release just short of the point, such as position: 299.5, lands on 640 with tolerance: 1 and on 300 without, so it would pin the rule.
| const barrels = fs | ||
| .readdirSync(here) | ||
| .filter(name => /^index\.(ts|tsx|js|mjs)$/.test(name)); | ||
| for (const barrel of barrels) { | ||
| expect(fs.readFileSync(path.join(here, barrel), 'utf8')).not.toMatch( | ||
| /resolveSnapPoint/, | ||
| ); | ||
| } |
There was a problem hiding this comment.
Non-blocking: packages/core/src/motion/ has no index.* file, so barrels is always empty and this loop asserts nothing. The root-index check above already covers the barrels the root star-re-exports, BottomSheet/index.ts among them; either point the loop at the published subpath barrels the root does not star-re-export (such as ./Layer), or drop it and say "package root and exports map" in the title.
There was a problem hiding this comment.
This looks ready to merge: resolveSnapPoint reproduces BottomSheet's and the pager's landings exactly, and the change stays within the current touch-presentation and release-velocity specs. Because the base is stack/8386, the CI and Lint workflows have not run on it, so please confirm they pass once it targets main. Two optional test tweaks would make resolveSnapPoint.test.ts prove what its titles say: release the tolerance case just short of the snap point (at 299.5 px, say) instead of past it, and point the barrel loop at a barrel that exists or drop it.
[Automated review]
…Point Where a release lands is decided in one place: motion/resolveSnapPoint.ts. A slow release lands on the snap point nearest where it would rest; a flick (flickThreshold or faster) goes at least to the next snap point in its direction; with start, a release moving back toward it cancels to it (spec:AST-094 FR37); with fromIndex and maxSteps it moves at most that many points. selectSnapPoint in projection.ts stays the math primitive, and paging moves to selectPage.ts on top of resolveSnapPoint. Internal: not exported from the package (a test locks that). No behavior change. Split from #8565 so the public drag-to-snap-points API can build on it;
…Point Where a release lands is decided in one place: motion/resolveSnapPoint.ts. A slow release lands on the snap point nearest where it would rest; a flick (flickThreshold or faster) goes at least to the next snap point in its direction; with start, a release moving back toward it cancels to it (spec:AST-094 FR37); with fromIndex and maxSteps it moves at most that many points. selectSnapPoint in projection.ts stays the math primitive, and paging moves to selectPage.ts on top of resolveSnapPoint. Internal: not exported from the package (a test locks that). No behavior change. Split from #8565 so the public drag-to-snap-points API can build on it; #8565 keeps the bottom sheet's adoption.
|
(Posted by Cindy's agent.) Superseded by #8663, which put the one release policy (resolveSnapPoint) on main; the pager and BottomSheet already use it. |
Stacked on #8386 (BottomSheet on the gesture recognizers). Until that lands, this diff includes it; this pull request's own change is its single commit.
What it does
One internal module with one job: pick the snap point a release lands on.
resolveSnapPoint(packages/core/src/motion/resolveSnapPoint.ts) takes plain inputs (ascending snap points, position, velocity, a flick threshold, an optional projection, an optional start and step limit) and returns the snap point's index plus the projected rest position it judged from.projection.start, a release moving back toward where the drag began cancels to it (spec:AST-094 FR37).fromIndexandmaxSteps, it stays within that many snap points (a pager's one page per release).It sits on
selectSnapPoint(projection + nearest), which stays the math primitive; both doc comments say so, so nobody adds a second "pick the release target" helper. Names follow the platform glossary (resolveSnapPoint,flickThreshold). It isn't exported from the package or any barrel (resolveSnapPoint.test.tslocks that). It contains no component names.Adopters
resolveSheetReleasecalls it with the sheet's UIKit thresholds (sheet.release.fastSpeed,detentTolerance,projectionSeconds,minProjectionSpeed) instead of its own projection, flick and cancel code. The code moved here unchanged; the sheet's springs and dismiss mapping stay the sheet's.selectPagemoves tomotion/selectPage.tsand calls it: no flick, one page per release, and the paging deceleration rate expressed as the seconds it projects (the same projection to floating-point rounding).resolveSnapPoint. The driver itself picks no landing; its rules do, and the sheet's rule now goes through this module.No behavior change
The existing release tests are the oracle and pass unchanged: BottomSheet's
sheetRelease.test.ts(UIKit-measured releases) anduseSheetGestures.test.ts, plusprojection.test.tsand the paging tests, now inselectPage.test.ts. Acrosspackages/core/src/motionandpackages/core/src/BottomSheet, 1,141 tests pass.resolveSnapPoint.test.tsadds direct cases for each rule and the export lock. The real-browser check is the BottomSheet detent and drag specs, which this PR's CI runs because the change touches the BottomSheet folder.Size (gzip KB, minified)
Method: a fresh
packages/coredist at the base (#8386) and at this head; an entry re-exporting the component; esbuild bundle, minify, splitting, ESM, packages external. Desktop is the static-import closure; phone is all chunks.Every component that reaches the sheet gains about 0.1 KB. That's the module's general inputs (optional projection, step limit), which the sheet's inline code didn't need. The pager has no shipped consumer yet.
Testing
pnpm vitest run --project ui packages/core/src/motion packages/core/src/BottomSheet: 1,141 pass.[chore]changeset (internal, no behavior change).Co-authored with vjeux (the sheet's release code moves here).