Repository navigation
fix(RefreshControl): with Reduce Motion on a phone, a release cross-fades a list of up to 1,500 elements #11087
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
17
commits into
meta:main
Choose a base branch
from
vjeux:fix/refresh-control-reduce-motion-cross-fade
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.
+1,380
−29
Draft
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b9862e3
test(RefreshControl): the list shows on every Reduce Motion frame
vjeux 699a663
fix(RefreshControl): a Reduce Motion release cross-fades the list
vjeux f4d930d
chore(sandbox): a RefreshControl page for a phone check
vjeux 2468fe1
docs(architecture): name the Reduce Motion cross-fade on internal/touch
vjeux c625a0d
chore: a changeset for the Reduce Motion cross-fade
vjeux 5bbd943
fix(RefreshControl): the cross-fade's copy shows the indicator band
vjeux 740fdd0
fix(RefreshControl): an end into the inset cross-fades onto its slide
vjeux 8391a16
docs(architecture): the cross-fade's copy covers a refresh's end
vjeux 1ff7ccb
fix(RefreshControl): a refresh begun mid-fade keeps its inset
vjeux a16514c
Merge main
vjeux 57ba8f6
Merge main
vjeux 402e9bd
fix(RefreshControl): a release that moves nothing lays no copy
vjeux 25f17e1
Merge main
vjeux 15b3624
fix(RefreshControl): an unmount ends a cross-fade in flight
vjeux ae54d25
Merge main
vjeux 8e7ea02
Merge main into the RefreshControl cross-fade
cixzhang 165c74d
docs(changeset): bound the RefreshControl cross-fade's claim
cixzhang 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
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 | ||
| --- | ||
|
|
||
| [fix] With Reduce Motion on a phone, Lab's RefreshControl keeps its list in view when a pull is released or a refresh ends. It cross-fades to its new place instead of blanking between the two. The cross-fade comes from a new export of `internal/touch`; apps import nothing new. | ||
|
|
||
| @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
118 changes: 118 additions & 0 deletions
118
apps/sandbox/src/app/(raw)/pages/refresh-control/page.tsx
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,118 @@ | ||
| // Copyright (c) Meta Platforms, Inc. and affiliates. | ||
|
|
||
| 'use client'; | ||
|
|
||
| /** | ||
| * @file page.tsx | ||
| * @input Nothing | ||
| * @output A bare page with a RefreshControl list in a fixed-height card, | ||
| * above rows that make the document scroll. A pull past the trigger | ||
| * refreshes for 1.5 s: the list settles below the spinner, then returns to | ||
| * the top. | ||
| * @position A raw page, with no sandbox chrome, for checking a pull to refresh | ||
| * on a phone, with motion and under Reduce Motion. The page scrolls with | ||
| * the document. | ||
| */ | ||
|
|
||
| import {useCallback, useState} from 'react'; | ||
| import * as stylex from '@stylexjs/stylex'; | ||
| import {REFRESH_REVEAL_VAR, useRefreshControl} from '@astryxdesign/lab'; | ||
| import {Card} from '@astryxdesign/core/Card'; | ||
| import {VStack} from '@astryxdesign/core/Layout'; | ||
| import {List, ListItem} from '@astryxdesign/core/List'; | ||
| import {Spinner} from '@astryxdesign/core/Spinner'; | ||
| import {Heading, Text} from '@astryxdesign/core/Text'; | ||
|
|
||
| const REFRESH_MS = 1500; | ||
|
|
||
| const LIST_ROWS = Array.from( | ||
| {length: 30}, | ||
| (_, index) => `Message ${index + 1}`, | ||
| ); | ||
| const PAGE_ROWS = Array.from({length: 30}, (_, index) => `Row ${index + 1}`); | ||
|
|
||
| const styles = stylex.create({ | ||
| scroller: {height: '100%', overflowY: 'auto'}, | ||
| content: {position: 'relative'}, | ||
| // The indicator's band sits above the content, inside a box that clips it. | ||
| band: { | ||
| position: 'absolute', | ||
| insetInline: 0, | ||
| bottom: '100%', | ||
| height: '100lvh', | ||
| overflow: 'hidden', | ||
| pointerEvents: 'none', | ||
| }, | ||
| indicator: { | ||
| position: 'absolute', | ||
| insetInline: 0, | ||
| bottom: 0, | ||
| height: 60, | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| justifyContent: 'center', | ||
| }, | ||
| revealed: (opacity: string) => ({opacity}), | ||
| }); | ||
|
|
||
| export default function RefreshControlPage() { | ||
| const [count, setCount] = useState(0); | ||
| const onRefresh = useCallback(async () => { | ||
| await new Promise<void>(resolve => { | ||
| setTimeout(resolve, REFRESH_MS); | ||
| }); | ||
| setCount(value => value + 1); | ||
| }, []); | ||
| const control = useRefreshControl({onRefresh, announce: 'Refreshing'}); | ||
| return ( | ||
| <VStack gap={4} padding={4}> | ||
| <VStack gap={1}> | ||
| <Heading level={1}>Refresh control</Heading> | ||
| <Text color="secondary"> | ||
| With the messages at the top, pull them down past the spinner and let | ||
| go. They wait below the spinner while the refresh runs, then go back | ||
| to the top. | ||
| </Text> | ||
| </VStack> | ||
| <Text>{`Refreshed ${count} times`}</Text> | ||
| <Card height="60dvh" padding={0}> | ||
| <div | ||
| {...stylex.props(styles.scroller)} | ||
| role="region" | ||
| aria-label="Messages" | ||
| tabIndex={0}> | ||
| <div | ||
| ref={control.contentRef} | ||
| {...stylex.props(styles.content)} | ||
| aria-busy={control.isRefreshing || undefined}> | ||
| <List hasDividers> | ||
| {LIST_ROWS.map(row => ( | ||
| <ListItem key={row} label={row} /> | ||
| ))} | ||
| </List> | ||
| <div {...stylex.props(styles.band)}> | ||
| <div | ||
| ref={control.indicatorRef} | ||
| aria-hidden | ||
| {...stylex.props(styles.indicator)}> | ||
| <span | ||
| {...stylex.props( | ||
| styles.revealed(`var(${REFRESH_REVEAL_VAR}, 0)`), | ||
| )}> | ||
| <Spinner size="lg" shade="subtle" /> | ||
| </span> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </Card> | ||
| <VStack gap={2}> | ||
| {PAGE_ROWS.map(row => ( | ||
| <Text key={row} color="secondary"> | ||
| {row} | ||
| </Text> | ||
| ))} | ||
| </VStack> | ||
| </VStack> | ||
| ); | ||
| } |
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This holds only for lists the copy can take: over 1,500 elements,
playReducedMotionCrossFadereturns null and the animator still dips the list through opacity 0 (transientCopy.ts:47-52). Suggested: "…keeps a list of up to 1,500 elements in view when a pull is released or a refresh ends; a larger list keeps the dip."