Skip to content
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

Fix elements dissapearing due to high values set to threshold props in ReanimatedSwipeable #3153

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 3 additions & 40 deletions src/components/ReanimatedSwipeable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
import type { PanGestureHandlerProps } from '../handlers/PanGestureHandler';
import type { PanGestureHandlerEventPayload } from '../handlers/GestureHandlerEventPayload';
import Animated, {
Extrapolation,
SharedValue,
interpolate,
runOnJS,
Expand Down Expand Up @@ -232,9 +231,6 @@ const Swipeable = forwardRef<SwipeableMethods, SwipeableProps>(
const rightWidth = useSharedValue<number>(0);
const rightOffset = useSharedValue<number | null>(null);

const leftActionTranslate = useSharedValue<number>(0);
const rightActionTranslate = useSharedValue<number>(0);

const showLeftProgress = useSharedValue<number>(0);
const showRightProgress = useSharedValue<number>(0);

Expand Down Expand Up @@ -325,12 +321,7 @@ const Swipeable = forwardRef<SwipeableMethods, SwipeableProps>(
[0, 0, 1]
)
: 0;
leftActionTranslate.value = interpolate(
showLeftProgress.value,
[0, Number.MIN_VALUE],
[-10000, 0],
Extrapolation.CLAMP
);

showRightProgress.value =
rightWidth.value > 0
? interpolate(
Expand All @@ -339,12 +330,6 @@ const Swipeable = forwardRef<SwipeableMethods, SwipeableProps>(
[1, 0, 0]
)
: 0;
rightActionTranslate.value = interpolate(
showRightProgress.value,
[0, Number.MIN_VALUE],
[-10000, 0],
Extrapolation.CLAMP
);
};

const dispatchImmediateEvents = useCallback(
Expand Down Expand Up @@ -466,19 +451,8 @@ const Swipeable = forwardRef<SwipeableMethods, SwipeableProps>(
},
};

const leftAnimatedStyle = useAnimatedStyle(
() => ({
transform: [
{
translateX: leftActionTranslate.value,
},
],
}),
[leftActionTranslate]
);

const leftElement = renderLeftActions && (
<Animated.View style={[styles.leftActions, leftAnimatedStyle]}>
<Animated.View style={[styles.leftActions]}>
{renderLeftActions(
showLeftProgress,
appliedTranslation,
Expand All @@ -492,19 +466,8 @@ const Swipeable = forwardRef<SwipeableMethods, SwipeableProps>(
</Animated.View>
);

const rightAnimatedStyle = useAnimatedStyle(
() => ({
transform: [
{
translateX: rightActionTranslate.value,
},
],
}),
[rightActionTranslate]
);

const rightElement = renderRightActions && (
<Animated.View style={[styles.rightActions, rightAnimatedStyle]}>
<Animated.View style={[styles.rightActions]}>
{renderRightActions(
showRightProgress,
appliedTranslation,
Expand Down
Loading