-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Remove withDecay
velocity fix on Web
#4462
Merged
kacperkapusciak
merged 3 commits into
main
from
@kacperkapusciak/remove-decay-velocity-fix
May 17, 2023
Merged
Remove withDecay
velocity fix on Web
#4462
kacperkapusciak
merged 3 commits into
main
from
@kacperkapusciak/remove-decay-velocity-fix
May 17, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tomekzaw
approved these changes
May 16, 2023
piaskowyk
approved these changes
May 17, 2023
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.
I created an issue with a solution if someone encounters a problem with this breaking change.
fluiddot
pushed a commit
to wordpress-mobile/react-native-reanimated
that referenced
this pull request
Jun 5, 2023
## Summary In software-mansion#4270 withDecay rubberBandFactor got fixed on the Web with a fix where velocity got multiplied by `1000` to overcome an issue present in RNGH. This got addressed in software-mansion/react-native-gesture-handler#2443 and released in Gesture Handler 2.10 thus making the fix unnecessary. ## Recordings ### Before with RNGH 2.10 https://github.com/software-mansion/react-native-reanimated/assets/39658211/3caf7961-3f0e-4a00-9889-18da33dbfd32 ### After with RNGH 2.10 https://github.com/software-mansion/react-native-reanimated/assets/39658211/2ca02d9f-bfd6-4e13-83c2-aaa6312e8e6a ## Test plan Run this snippet in WebExample <details open> <summary>Code example</summary> ```jsx import React from 'react'; import {StyleSheet, View} from 'react-native'; import Animated, { useAnimatedStyle, useSharedValue, withDecay, } from 'react-native-reanimated'; import { Gesture, GestureDetector, GestureHandlerRootView, } from 'react-native-gesture-handler'; const SIZE = 120; export default function App() { const offset = useSharedValue(0); const width = useSharedValue(0); const onLayout = event => { width.value = event.nativeEvent.layout.width; }; const pan = Gesture.Pan() .onChange(event => { // highlight-next-line offset.value += event.changeX; }) .onFinalize(event => { // highlight-start offset.value = withDecay({ velocity: event.velocityX, rubberBandEffect: true, clamp: [-(width.value / 2) + SIZE / 2, width.value / 2 - SIZE / 2], }); // highlight-end }); const animatedStyles = useAnimatedStyle(() => ({ transform: [{translateX: offset.value}], })); return ( <GestureHandlerRootView style={styles.container}> <View onLayout={onLayout} style={styles.wrapper}> <GestureDetector gesture={pan}> <Animated.View style={[styles.box, animatedStyles]} /> </GestureDetector> </View> </GestureHandlerRootView> ); } const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', justifyContent: 'center', height: '100%', }, wrapper: { flex: 1, width: '100%', alignItems: 'center', justifyContent: 'center', }, box: { height: SIZE, width: SIZE, backgroundColor: '#b58df1', borderRadius: 20, cursor: 'grab', alignItems: 'center', justifyContent: 'center', }, }); ``` </details>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
In #4270 withDecay rubberBandFactor got fixed on the Web with a fix where velocity got multiplied by
1000
to overcome an issue present in RNGH.This got addressed in software-mansion/react-native-gesture-handler#2443 and released in Gesture Handler 2.10 thus making the fix unnecessary.
Recordings
Before with RNGH 2.10
Screen.Recording.2023-05-16.at.15.31.30.mov
After with RNGH 2.10
Screen.Recording.2023-05-16.at.15.29.02.mov
Test plan
Run this snippet in WebExample
Code example