Repository navigation
feat(liftFromTrigger): one opt-in lift-from-trigger presentation #8485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
vjeux
wants to merge
77
commits into
meta:main
Choose a base branch
from
vjeux:uikit/c20-lift
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+5,518
−134
Draft
Changes from 72 commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
3dd581e
feat(core): one progress module for the motion foundation
vjeux 3cfb3b1
refactor(animatedLayout): take the settle spring's progress from prog…
cixzhang 273da1e
feat(core): the rect morph's paths, the rect a grow-out presentation …
vjeux f1149cd
Merge remote-tracking branch 'origin/main' into motion/morph-path
cixzhang 131ca14
feat(core): one rect morph for touch presentations that grow out of a…
vjeux f19df27
fix(rectMorph): a handed-in animator stays on the element through a c…
cixzhang e3a43d0
fix(motion): one timed curve keeps a retargeted velocity, for the pag…
cixzhang c99210a
fix(rectMorph): a timed motion from rest plays its easing as given
cixzhang 3272828
docs(rectMorph): the timing follows the component's motion record
cixzhang df642e0
Merge main into motion/morph-path
vjeux 8c8f726
Merge motion/morph-path into motion/rect-morph
vjeux 3fdca8f
fix(rectMorph): AST-094 links the morph; the proof imports a safe test
vjeux d4903e2
test(SnapPaging): the pager's bundle lists the progress module
vjeux 1b794af
test(motion): the popover's proofs read Popover's live geometry
vjeux 5dd6a6a
Merge motion/morph-path into motion/rect-morph
vjeux 3bfa524
refactor(motion): one eased progress, with a retargeted velocity
vjeux ad7f8fb
test(motion): the popover's turn-around reads Popover's live curves
vjeux 99d352d
Merge motion/morph-path into motion/rect-morph
vjeux 33a3ee8
docs(changeset): the rect morph's note names the eased-progress move
vjeux 2bf8f8a
Merge main into motion/rect-morph
vjeux 822013a
test(motion): the popover's turn-around compares opacity as drawn
vjeux 2651e17
Merge motion/morph-path into motion/rect-morph
vjeux 6354fa3
fix(motion): a popover's morph never reads an opacity below 0
vjeux dcfa346
Merge motion/morph-path into motion/rect-morph
vjeux 6b6310c
test(motion): the morph proofs drop the menu's old straight line
vjeux 9d6c0a2
feat(lift): one opt-in lift-from-trigger presentation
vjeux a13c9b0
docs(lift): the lift's springs are the caller's, not motion roles
vjeux b3e79df
refactor(lift): the lift holds input through the layer runtime's inpu…
vjeux 68c64c1
refactor(liftFromTrigger): the lift-from-trigger module takes its rec…
vjeux d2c974e
test(liftFromTrigger): a lifted list item leaves its list valid and t…
vjeux e0eb8e1
fix(liftFromTrigger): an li holds a list item's spot, and takes no nu…
vjeux 08cb1b7
test(liftFromTrigger): the zoom's copy of a source, through the lift …
vjeux d5fb378
feat(liftFromTrigger): liftCopy, the zoom's copy of a source through …
vjeux 9d4bf2b
test(liftFromTrigger): browser proofs of the zoom's copy
vjeux 5ef5f36
docs(layer-runtime): the lift-from-trigger module exists
vjeux 1d704a2
fix(liftFromTrigger): each spring reaches the rect morph as a motion
vjeux 23bf224
refactor(liftFromTrigger): the caller names the lift's marks
vjeux fe3b5c2
docs(liftFromTrigger): comments say why, not which record
vjeux 6a58c11
test(liftFromTrigger): a finger taps the growing lift, from the harness
vjeux 8e4f4c5
docs(liftFromTrigger): comment sentences keep to 25 words
vjeux 96ef395
test(liftFromTrigger): a tall source fits between the gutters
vjeux da70e02
fix(liftFromTrigger): the lift fits between the gutters on both axes
vjeux 67116fb
test(liftFromTrigger): a pinch on the lifted backdrop zooms the page
vjeux ff7e468
fix(liftFromTrigger): the lift layer keeps the page's pinch-zoom
vjeux 9e7b0b4
test(liftFromTrigger): a drop mid-rise turns the tint with its velocity
vjeux 917d51d
fix(liftFromTrigger): the tint fades on the animator's backdrop channel
vjeux 50f150c
refactor(liftFromTrigger): the shadow rides a rect morph of its own
vjeux 87b4151
test(liftFromTrigger): a dropped row's margin returns with no transition
vjeux 29677fd
fix(liftFromTrigger): the restore flushes style with a non-geometry read
vjeux 5f36262
fix(liftFromTrigger): the lifted trigger casts no shadow
vjeux d2e52c0
test(liftFromTrigger): the growth sample reads its animations at 30 ms
vjeux bae645b
fix(liftFromTrigger): a source lifts at its layout width
vjeux 4e989c6
feat(liftFromTrigger): a surface can show as the layer shows
vjeux a0eec83
feat(liftFromTrigger): the caller can pin styles with the lift's own
vjeux 86d8f07
fix(liftFromTrigger): the pointer watch reads the window's input stream
vjeux 78442d4
Merge commit 'ebb9ddecc0219bc6eaf3caf40b6e4e45f81dc0e5' into motion/r…
cixzhang 09bb9c2
fix(motion): existing callers keep easedProgress's values; the pager …
cixzhang b24c23c
test(paging): a retarget at the first instant goes on at the starting…
cixzhang 9d40852
test(paging): a 0 ms move is on its target at once, at rest
cixzhang 6c17632
test(motion): compare the callers' values with copies of the earlier …
cixzhang fc3aaf9
refactor(liftFromTrigger): drop the zoom's copy until its first user
vjeux aed8400
refactor(liftFromTrigger): drop the uncalled surface close
vjeux 8cf7cdd
refactor(liftFromTrigger): one module, with its geometry inside
vjeux 0cd53f6
refactor(liftFromTrigger): no hook of its own
vjeux 6f44618
refactor(liftFromTrigger): a surface fades in beside the lift
vjeux 3016130
docs(layer-runtime): name the lift module's entry points
vjeux 20be748
Merge the rect morph's head
vjeux 215cff7
docs(liftFromTrigger): the attribute's doc names the marks it sets
vjeux 18fcf70
Merge commit '7e7fbae0fa0ba389ad37fafdb26e6495fab19fd4' into motion/r…
cixzhang 2095d4f
Merge the rect morph's merge of main
vjeux 0a995e2
test(liftFromTrigger): a second drop keeps the return in flight
vjeux 3a5a35c
fix(liftFromTrigger): a second drop leaves the return in flight
vjeux c16093a
docs(liftFromTrigger): the gap line and onLayerShown say what holds
vjeux 4380723
docs(liftFromTrigger): the README's listeners and onLayerShown's limits
vjeux 5eb0610
test(liftFromTrigger): a lifted last row keeps its rounded corners
vjeux 8db9bf4
fix(liftFromTrigger): a lifted row keeps its corner radii
vjeux aa2f8e5
docs(layer-runtime): INV15 lists the lift module's functions
vjeux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [chore] Internal: one opt-in lift-from-trigger presentation for touch surfaces. The trigger itself lifts into the top layer above a tinted backdrop; a surface fades in beside it on the shared rect morph; the trigger returns to its place. Translate, scale and opacity only; nothing mounted at rest, three elements while lifted, and no shadow. Not exported from the package entry point; no component uses it yet. | ||
|
|
||
| @vjeux |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [chore] Internal: the rect morph's paths, the geometry touch presentations share when they grow out of a source rect and shrink back into it. `lerpPath` (a straight line between two rects) and `edgeGrowPath` (UIKit's popover, growing out of a point on its edge) name the rect an element shows at each progress, and say how an interrupted motion continues in their own law; `morphCurves` turns a path into compositor curves (`translate`, `scale` and a companion `opacity`). Not exported from the package entry point; no component uses them yet. | ||
|
|
||
| @vjeux |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [chore] Internal: the rect morph, one way for a touch presentation to grow out of a source rect and shrink back into it. `createRectMorph` presents an element along a path (`lerpPath`, `edgeGrowPath`) and dismisses it back on a copy or on itself, each continuing the other from the rect on screen. Each play takes the timing the component's motion record names (AST-094 FR45): a duration and easing, or a spring, starting from the velocity it is given. Reduced Motion is left to the animator. `easedProgress` moves to the progress helpers with the same values. `timedCurve` joins them: a timed motion that keeps a retargeted velocity, for the pager and the rect morph. Not exported from the package entry point; no component uses it yet. | ||
|
|
||
| @vjeux |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # LiftFromTrigger | ||
|
|
||
| The one lift-from-trigger presentation, internal to core and opt-in. A | ||
| surface that chooses it (ContextMenu's touch invocation) lifts its trigger | ||
| out of the page above a tinted backdrop, fades a surface (a menu) in beside it, and | ||
| returns the trigger to its place. Nothing else gets it by default, and any | ||
| surface that lifts uses this module, never a copy of it. | ||
| Nothing here is exported from the package entry point; components import it | ||
| by path. | ||
|
|
||
| Layer stays generic. The top layer, dismissal and the input hold | ||
| (`Layer/inputHold.ts`) belong to Layer; the lift only uses them. Its | ||
| motion is the rect morph's (`motion/rectMorph.ts`), and its springs, scale | ||
| rule and gap are the caller's own. | ||
|
|
||
| ## What a lift adds | ||
|
|
||
| The trigger itself lifts, not a copy: it becomes a manual popover in the top | ||
| layer, laid out at its own size where it stood, so no clipping, transformed | ||
| or stacking ancestor cuts or covers it, and an empty placeholder after it | ||
| holds its spot, so the page does not move. In a list the placeholder is an | ||
| `li` that is not a list item, so the list stays valid and keeps its numbers. | ||
| The trigger takes no hits while lifted: a tap on it is a tap on the backdrop. | ||
| While lifted the page has three | ||
| elements more, whatever the trigger holds: the lift layer (its `::backdrop` | ||
| is the tint); an empty box at the lifted rect for the surface to be placed | ||
| against (anchor positioning follows transforms, so a box inside the trigger | ||
| would move with it); and the placeholder. The lifted trigger casts no | ||
| shadow. The input hold's shield joins while the lift grows and while it | ||
| closes: never more than four (`spec:AST-017` FR60, DEC-29). At rest there | ||
| is nothing. | ||
|
|
||
| ## Motion | ||
|
|
||
| Every motion is `translate`, `scale` or `opacity` on the compositor | ||
| (`spec:AST-094` FR5): the trigger and the surface on the rect morph, | ||
| which continues an interrupted motion with the velocity on screen (FR6); the | ||
| tint on the animator, as the opacity of the layer's `::backdrop`, so a drop | ||
| while it rises turns it with its velocity too. A | ||
| tap or a drag that lands while the lift grows and the surface enters reaches nothing | ||
| (FR35). The close holds the layer until the trigger is back and every press | ||
| on the layer has lifted. Its timers and | ||
| document listeners end with it, and an unmount ends everything at once | ||
|
astracat-bot[bot] marked this conversation as resolved.
Resolved
|
||
| (FR24). Reduce Motion is the animator's (`design:reduced-motion`). | ||
|
|
||
| ## Files | ||
|
|
||
| | File | What it is | | ||
| | ------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | `liftFromTrigger.ts` | `createLiftFromTrigger`: lift a trigger, fade a surface in beside it, drop, end. Its geometry: how far the trigger grows, where it lands inside the layer runtime's gutter, which side the surface takes. | | ||
| | `__tests__/liftFromTrigger.interaction.browser.spec.ts` | Browser proofs (Chromium and WebKit): the top layer, the placeholder, the properties that move, counts, leaks. | | ||
126 changes: 126 additions & 0 deletions
126
packages/core/src/liftFromTrigger/__tests__/liftFromTrigger.fixture.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| // Copyright (c) Meta Platforms, Inc. and affiliates. | ||
|
|
||
| /** | ||
| * @file liftFromTrigger.fixture.ts | ||
| * @input Nothing: bundled by esbuild and injected into a blank page | ||
| * @output A page with a list of rows in a clipping, transformed panel, and a | ||
| * menu popover beside it. The first row is rounded by `:first-child`, and | ||
| * the second holds twelve elements. `window.__lift` lifts a row, fades the | ||
| * menu in and closes it, drops and ends, and logs taps and clicks | ||
| * @position Browser fixture of liftFromTrigger.interaction.browser.spec.ts; test-only | ||
| */ | ||
|
|
||
| import { | ||
| createLiftFromTrigger, | ||
| type LiftFromTriggerOptions, | ||
| type LiftFromTriggerResult, | ||
| } from '../liftFromTrigger'; | ||
|
|
||
| interface LiftLog { | ||
| backdropTaps: number; | ||
| clicks: string[]; | ||
| } | ||
|
|
||
| /** The page's handle on its lift. */ | ||
| export interface LiftFixture { | ||
| log: LiftLog; | ||
| lift: (id: string, springResponse?: number) => LiftFromTriggerResult | null; | ||
| presentMenu: () => void; | ||
| closeMenu: () => void; | ||
| showMenu: () => void; | ||
| drop: () => void; | ||
| dispose: () => void; | ||
| isLifted: () => boolean; | ||
| } | ||
|
|
||
| declare global { | ||
| interface Window { | ||
| __lift: LiftFixture; | ||
| } | ||
| } | ||
|
|
||
| document.documentElement.style.cssText = | ||
| '--color-overlay: rgba(1, 18, 40, 0.4); --spacing-4: 16px;'; | ||
| document.body.style.margin = '0'; | ||
| document.body.style.font = '16px sans-serif'; | ||
| const deep = Array.from( | ||
| {length: 3}, | ||
| (_, i) => | ||
| `<div><span>${i * 3 + 1}</span><span>${i * 3 + 2}</span><span>${i * 3 + 3}</span></div>`, | ||
| ).join(''); | ||
| document.body.innerHTML = ` | ||
| <style> | ||
| .panel { position: absolute; left: 20px; top: 120px; width: 335px; height: 250px; overflow: hidden; transform: translateX(0.5px); border-radius: 12px; } | ||
| ul { list-style: none; margin: 0; padding: 0; } | ||
| li { box-sizing: border-box; height: 60px; padding: 0 16px; display: flex; align-items: center; gap: 8px; background: rgb(255, 255, 255); border-bottom: 1px solid rgb(221, 221, 221); color: rgb(17, 17, 17); } | ||
| li:first-child { border-radius: 12px 12px 0 0; } | ||
| #menu { position: fixed; inset: auto; margin: 0; padding: 0; border: 0; left: 40px; top: 420px; width: 250px; height: 180px; background: rgb(238, 238, 238); border-radius: 16px; } | ||
| </style> | ||
| <div class="panel"> | ||
| <ul id="list"> | ||
| <li id="row1">Row 1</li> | ||
| <li id="row2" style="color: rgb(0, 0, 200)">${deep}</li> | ||
| <li id="row3">Row 3</li> | ||
| <li id="row4">Row 4</li> | ||
| </ul> | ||
| </div> | ||
| <button id="page" style="position: absolute; left: 20px; top: 640px; width: 335px; height: 120px">page</button> | ||
| <div id="chip" style="position: absolute; left: 20px; top: 40px; width: 100.4px; line-height: 20px; background: rgb(255, 255, 255)"><span id="chip-a" style="display: inline-block; width: 50.2px; height: 20px"></span><span id="chip-b" style="display: inline-block; width: 50.2px; height: 20px"></span></div> | ||
| <div id="menu" popover="manual"><div role="menu" aria-label="Actions">Menu</div></div>`; | ||
|
|
||
| function element(id: string): HTMLElement { | ||
| const found = document.getElementById(id); | ||
| if (found == null) { | ||
| throw new Error(`missing #${id}`); | ||
| } | ||
| return found; | ||
| } | ||
|
|
||
| const log: LiftLog = {backdropTaps: 0, clicks: []}; | ||
| document.addEventListener( | ||
| 'click', | ||
| event => { | ||
| const target = event.target; | ||
| if (target instanceof Element) { | ||
| log.clicks.push(target.id || target.tagName.toLowerCase()); | ||
| } | ||
| }, | ||
| true, | ||
| ); | ||
|
|
||
| const lift = createLiftFromTrigger(); | ||
|
|
||
| function options(response: number): LiftFromTriggerOptions { | ||
| const spring = {response, dampingRatio: 0.9}; | ||
| return { | ||
| motion: { | ||
| lift: spring, | ||
| drop: spring, | ||
| clear: spring, | ||
| surfaceIn: spring, | ||
| }, | ||
| scale: {maxScale: 1.15, scaleUpPoints: 26}, | ||
| attribute: 'data-lift', | ||
| onBackdropTap: () => { | ||
| log.backdropTaps += 1; | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| window.__lift = { | ||
| log, | ||
| lift: (id, springResponse = 0.3) => | ||
| lift.lift(element(id), options(springResponse)), | ||
| showMenu: () => element('menu').showPopover(), | ||
| presentMenu: () => { | ||
| element('menu').showPopover(); | ||
| lift.presentSurface( | ||
| element('menu').querySelector<HTMLElement>('[role="menu"]') ?? | ||
| element('menu'), | ||
| ); | ||
| }, | ||
| closeMenu: () => element('menu').hidePopover(), | ||
| drop: () => lift.drop(), | ||
| dispose: () => lift.dispose(), | ||
| isLifted: () => lift.isLifted(), | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.