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

Add "onSwipedBegin" prop #95

Open
yotam-frid opened this issue Jan 9, 2023 · 0 comments
Open

Add "onSwipedBegin" prop #95

yotam-frid opened this issue Jan 9, 2023 · 0 comments

Comments

@yotam-frid
Copy link

yotam-frid commented Jan 9, 2023

Hi! 👋

Firstly, thanks for your work on this project! It's a huge help and very convenient to work with.

Today I used patch-package to patch react-native-deck-swiper@2.0.12 for the project I'm working on.

I added a prop to allow invoking a callback before the swipe animation begins, in order to build a more responsive interface.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-deck-swiper/Swiper.js b/node_modules/react-native-deck-swiper/Swiper.js
index 1a657b3..16567cd 100644
--- a/node_modules/react-native-deck-swiper/Swiper.js
+++ b/node_modules/react-native-deck-swiper/Swiper.js
@@ -414,6 +414,7 @@ class Swiper extends Component {
     mustDecrementCardIndex = false
   ) => {
     this.setState({ panResponderLocked: true })
+    this.props.onSwipedBegin();
     this.animateStack()
     Animated.timing(this.state.pan, {
       toValue: {
@@ -974,6 +975,7 @@ Swiper.defaultProps = {
   marginBottom: 0,
   marginTop: 0,
   onSwiped: cardIndex => { },
+  onSwipedBegin: () => { },
   onSwipedAborted: () => { },
   onSwipedAll: () => { },
   onSwipedBottom: cardIndex => { },
diff --git a/node_modules/react-native-deck-swiper/index.d.ts b/node_modules/react-native-deck-swiper/index.d.ts
index 1ef616e..06879e9 100644
--- a/node_modules/react-native-deck-swiper/index.d.ts
+++ b/node_modules/react-native-deck-swiper/index.d.ts
@@ -32,6 +32,7 @@ declare module 'react-native-deck-swiper' {
     marginBottom?: number;
     marginTop?: number;
     onSwiped?: (cardIndex: number) => void;
+    onSwipedBegin: () => void;
     onSwipedAborted?: () => void;
     onSwipedAll?: () => void;
     onSwipedBottom?: (cardIndex: number) => void;

This issue body was partially generated by patch-package.

@yotam-frid yotam-frid changed the title Add "invokeCallbacksBeforeAnimation" prop Add "onSwipedBegin" prop Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant