Skip to content

Animate scroll view rows, and let auto-scroll animate and repeat - #225

Draft
simonhamp wants to merge 1 commit into
mainfrom
feat/layout-animation
Draft

simonhamp wants to merge 1 commit into
mainfrom
feat/layout-animation

Conversation

@simonhamp

Copy link
Copy Markdown
Member

The renderer half of NativePHP/mobile-air#736. That PR parses the new attributes and does the core animation; this one makes the scroll views use them.

What changed

  • animate-layout on a scroll view, Android: each row of the LazyColumn / LazyRow is wrapped in a Box carrying Modifier.animateItem(). Rows are already keyed by node id, so a row kept across frames slides to its new place, a new one fades in and a removed one fades out. Without the prop the rows are composed exactly as before. iOS needs nothing here because core animates the scroll view node itself.
  • auto_scroll_token, both platforms: the request the scroll view follows is now the index plus the token. Asking for the same index with a new token scrolls again. Before, a repeated index did nothing, and the devnull app worked around that by remounting the scroll view with a new key.
  • auto_scroll_animated, both platforms: animate every move, the first one included, except a request the scroll view already had when it appeared. A screen still opens where it's meant to be instead of flying there. Without the prop the first move jumps and later ones animate, as now. On iOS, a view that set the prop jumps under Reduce Motion. Android's scroll animations follow the animator duration scale through Compose.
  • Docs: a scroll-view row in the boost skill.
  • tests/android/AnimateLayoutColumnTest: reorders a column with animate-layout (core's FlexContainer) and checks a child passes between its old and new place before landing, and that without the flag it jumps. It needs -PmobileRoot pointing at a mobile checkout with #736, since that's where LocalAnimateLayoutChildren lives. CI doesn't run this module.

Watch for

  • Merge after Animate layout changes, and let auto-scroll animate and repeat mobile-air#736, or the new test module case won't compile against main. The renderer changes themselves only read props, so they're harmless against an older core.
  • Android native:list doesn't get animateItem() yet. Its rows go through several item builders (sections, sticky headers, the pager header) and I left it alone. iOS lists should animate through core, but I haven't checked.
  • Nothing has run on a device or simulator yet.

Testing

  • php -d auto_prepend_file= vendor/bin/pest: 527 passed.
  • Swift: swiftc -typecheck -wmo with mobile-air #736's NativeRender. Same 156 baseline errors as main, none new, and a planted error in the new scroll code showed up.
  • Kotlin: compileDebugKotlin in a copy of a built app's Android project with these renderers and #736's core, plus a planted error. tests/android against #736: 106 passed.

🤖 Generated with Claude Code

With `animate-layout` (parsed by nativephp/mobile, NativePHP/mobile-air#736)
the Android scroll view wraps each row in animateItem(), so keyed rows
slide to their new places, new ones fade in and removed ones fade out.
iOS needs nothing here: core animates the node.

Both scroll views read `auto_scroll_token`, so a new token asks for the
same child again, and `auto_scroll_animated`, which animates every move
except the one the view opens with. Under Reduce Motion a view that asked
for animated moves jumps instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
simonhamp added a commit to NativePHP/dev-null-app that referenced this pull request Nov 21, 2026
The scroll view now has animate-layout, so the rows the page keeps slide
to their new places and the ones it adds or drops fade, and
auto-scroll-animated, so the first move animates too. The focused commit
is keyed commit-<id>, as it is among the commits above it, so moving up
the tree slides that row rather than redrawing it.

Going back to a row the scroll view already went to used to mount the
scroll view again, which would make every row new. It now passes a new
auto-scroll-token instead.

These need NativePHP/mobile-air#736 and NativePHP/mobile-ui#225. Without
them the move jumps, as before, and asking for the same row twice in a
row doesn't scroll. The test that reads the new props skips until vendor
has them (Tests\Support\LayoutAnimation).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant