fix: stabilise animated callback node variables (#239)

This commit is contained in:
Mo Gorhom
2021-01-28 20:39:15 +01:00
committed by GitHub
parent 636782a214
commit 0444886d90

View File

@@ -262,16 +262,25 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
adjustedSnapPointsIndexes.push(-1);
}
return interpolate(position, {
inputRange: adjustedSnapPoints,
outputRange: adjustedSnapPointsIndexes,
extrapolate: Extrapolate.CLAMP,
});
}, [position, safeContainerHeight, snapPoints]);
return cond(
animatedIsLayoutReady,
interpolate(position, {
inputRange: adjustedSnapPoints,
outputRange: adjustedSnapPointsIndexes,
extrapolate: Extrapolate.CLAMP,
}),
0
);
}, [position, animatedIsLayoutReady, safeContainerHeight, snapPoints]);
const animatedPosition = useMemo(
() => abs(sub(safeContainerHeight, position)),
[safeContainerHeight, position]
() =>
cond(
animatedIsLayoutReady,
abs(sub(safeContainerHeight, position)),
safeContainerHeight
),
[safeContainerHeight, position, animatedIsLayoutReady]
);
/**