Skip to content

Commit 9ebee4c

Browse files
authored
fix: Invalid item position after release in reduced motion (#495)
## Description This PR fixes the active iteem getting stuck after being released issue when the reduced motion is enabled. ## Example recordings | Before | After | |-|-| | <video src="https://github.com/user-attachments/assets/c7ea289b-787e-462c-91e0-8e1fe4640f41" /> | <video src="https://github.com/user-attachments/assets/960487e6-9c2a-4057-8643-510f4f97fffb" /> |
1 parent 55b5269 commit 9ebee4c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/react-native-sortables/src/providers/shared/hooks/useItemLayout.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ export default function useItemLayout(
174174
progress: activationAnimationProgress.value
175175
}),
176176
({ active, itemPosition, progress }, prev) => {
177+
console.log('???', key, active, itemPosition, progress);
177178
if (!itemPosition || active) {
178179
interpolationStartValues.value = null;
179180
return;
@@ -189,7 +190,10 @@ export default function useItemLayout(
189190
areVectorsDifferent(prev.itemPosition, itemPosition, 1);
190191

191192
if (progress === 0) {
192-
if (interpolationStartValues.value) {
193+
// interpolationStartValues value is not set when the reduced motion
194+
// is enabled as the progress value changes immediately from 1 to 0
195+
// and the second if branch below is never entered
196+
if (interpolationStartValues.value || prev?.active) {
193197
interpolationStartValues.value = null;
194198
position.value = itemPosition;
195199
return;

0 commit comments

Comments
 (0)