-
Notifications
You must be signed in to change notification settings - Fork 22
feat: Make layout update in sync with positions change on grid columns change #441
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
feat: Make layout update in sync with positions change on grid columns change #441
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
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.
Pull Request Overview
This PR synchronizes layout updates with position changes when grid columns change, improving the visual smoothness of grid layout transitions. The changes focus on refactoring the animation system to make layout updates more immediate and responsive.
- Refactored the Fabric layout system to remove dependency on
layoutPositionand use debounced reset logic - Added a
resetMeasurementsfunction to clear measurement state when grid configuration changes - Enhanced the measurement provider to handle bulk dimension updates more efficiently
Reviewed Changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-native-sortables/src/types/providers/shared.ts | Adds resetMeasurements method to the measurements context type |
| packages/react-native-sortables/src/providers/shared/hooks/useItemLayoutStyle.ts | Refactors Fabric layout logic to remove layoutPosition dependency and add debounced reset |
| packages/react-native-sortables/src/providers/shared/MeasurementsProvider.ts | Implements resetMeasurements and improves bulk measurement update logic |
| packages/react-native-sortables/src/providers/layout/grid/GridLayoutProvider.tsx | Removes extra blank line |
| packages/react-native-sortables/src/components/SortableGrid.tsx | Adds effect to reset measurements when groups change |
| example/paper/metro.config.js | Adds reanimated exclusion to metro config |
| example/fabric/metro.config.js | Removes reanimated exclusion from metro config |
| example/app/src/examples/SortableGrid/features/DragHandleExample.tsx | Enhances example with dynamic height changes and overflow visibility |
packages/react-native-sortables/src/providers/shared/hooks/useItemLayoutStyle.ts
Show resolved
Hide resolved
packages/react-native-sortables/src/providers/shared/MeasurementsProvider.ts
Show resolved
Hide resolved
# [1.9.0](v1.8.0...v1.9.0) (2025-09-13) ### Bug Fixes * A bunch of issues, like shaky scroll, invalid grid layout, added items flickering ([#463](#463)) ([3b160b6](3b160b6)) * Active item touch start position on Android ([#462](#462)) ([7704729](7704729)) * Autoscroll exceeding bounds ([#473](#473)) ([eddd21b](eddd21b)) * Collapsible items implementation on the web ([#485](#485)) ([4d261db](4d261db)) * Collapsible items shift when size changes ([#451](#451)) ([e816b6a](e816b6a)) * Incorrect drag start position, no item size animation when teleported ([#456](#456)) ([1730fb8](1730fb8)) * Invalid builder bob config ([#475](#475)) ([11cf84a](11cf84a)) * Invalid grid layout on mount ([#461](#461)) ([a47ed72](a47ed72)) * onActiveItemDropped not being fired when item is touched quickly ([#449](#449)) ([f66d980](f66d980)) * Pre-release fixes and improvements ([#476](#476)) ([736fb7b](736fb7b)) * Prevent auto scroll from over scrolling content container ([#484](#484)) ([db586d7](db586d7)), closes [#473](#473) ### Features * Add custom shadow example to docs, clean up decoration style ([#466](#466)) ([1169928](1169928)) * Add example app build check CIs ([#480](#480)) ([5ad420c](5ad420c)) * Add style property to the handle component ([#477](#477)) ([28c9099](28c9099)) * Better collapsible auto-scroll behavior ([#457](#457)) ([2d24b14](2d24b14)), closes [#444](#444) * Collapsible items support ([#444](#444)) ([66c03b6](66c03b6)) * Data provider ([#472](#472)) ([5dc34b6](5dc34b6)) * Improved teleported items behavior ([#452](#452)) ([72dadef](72dadef)) * Make layout update in sync with positions change on grid columns change ([#441](#441)) ([ef37d8c](ef37d8c)) * New auto scroll implementation ([#454](#454)) ([c4facec](c4facec)), closes [#285](#285) [#453](#453) [#285](#285) ### Performance Improvements * Optimize rerenders caused by inlined callbacks, clean up drag state management ([#474](#474)) ([f5e3c89](f5e3c89)) * Reduce the number of layout calculations ([#442](#442)) ([f9c9875](f9c9875))
|
🎉 This issue has been resolved in version 1.9.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
This PR fixes weird animation when the number or grid columns/rows changes. The issue stemmed from the fact that the layout was calculated for the first time when the
mainGroupSizechanged, and then, for the second time, when all items were measured. Because the first layout calculation contained old (invalid) item dimensions that didn't take the changedmainGroupSizeinto account, items were animated to wrong positions and the animation was interrupted in the middle when all proper measurements came.The new implementation waits for all measurements before calculating the layout.
Changes showcase
Videos were recorded on Paper but on Fabric the improvement looks even better
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-08-04.at.01.09.22.mp4
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-08-04.at.01.06.28.mp4