Skip to content

Commit 3fa07c6

Browse files
authored
fix: Items stacking issue (#273)
## Description I was unable to reproduce the problem on my side but, based on the recordings in reported issues #270 and #272, I believe that the problem is related to what I try to fix here and will no longer occur after merging this PR.
1 parent 464756a commit 3fa07c6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@ export default function useItemLayoutStyles(
5757
// Inactive item updater
5858
useAnimatedReaction(
5959
() => ({
60+
canSwitchToAbsolute: canSwitchToAbsoluteLayout.value,
6061
hasProgress: hasActivationProgress.value,
6162
isActive: activeItemKey.value === key,
6263
position: itemPositions.value[key]
6364
}),
64-
({ hasProgress, isActive, position }) => {
65-
if (!canSwitchToAbsoluteLayout.value) {
65+
({ canSwitchToAbsolute, hasProgress, isActive, position }) => {
66+
if (!canSwitchToAbsolute) {
6667
// This affects all items rendered during the initial render when
6768
// the absolute layout is not yet enabled. All of these items have
6869
// no translation at the beginning and layoutX and layoutY are
@@ -77,7 +78,7 @@ export default function useItemLayoutStyles(
7778
return;
7879
}
7980

80-
if (hasProgress) {
81+
if (hasProgress && layoutX.value !== null && layoutY.value !== null) {
8182
// When the item is not active and has non-zero press progress,
8283
// it must have been dragged and released. In this case, we want
8384
// to animate the translation to the final position.
@@ -139,7 +140,7 @@ export default function useItemLayoutStyles(
139140
);
140141

141142
const animatedTranslationStyle = useAnimatedStyle(() => {
142-
if (!canSwitchToAbsoluteLayout.value) {
143+
if (layoutX.value === null || layoutY.value === null) {
143144
return RELATIVE_STYLE;
144145
}
145146

0 commit comments

Comments
 (0)