I am using a panresponder for each item of the flat-list. I want the pan responder to respond oly when the user swipes from left to right. But pan responder is getting active also when i am scrolling . I want that there will be no interuption while scrolling
Yes i have found a solution for this problem. It basically happens because the scrollView/Flatlist itself uses one responder to sense the gesture and i am also using one pan Responder . So two pan responders cannot work at same time. So the fix for this is when my pan responder becomes active at that time i disables my flatList scrolling and when the pan responder is released or the panresponderEnd method is called i enables the flatlist scrolling . So this way i solved my problem.
I also tell about a problem that faced when i was using panresponder that sometimes panresponder release method is not called , so the card get stucks in the middle. So i used panresponderEnd method which will be called every time when you release it .
Related
Can someone more experienced explain how the Pan Responder differs from the Gesture Responder and when it is better to use them.
Document:
Pan Responder:
https://reactnative.dev/docs/panresponder
Gesture Responder:
https://reactnative.dev/docs/gesture-responder-system
The Gesture Responder System is the basic system of how gestures are managed in React Native.
PanResponder is built on top of it and gives you a little more comfort when working with it. It also holds an InteractionManager to prevent interruption of active gestures.
While the Gesture Reponder System only provides you the native touch events, Pan Responder also provides you a gestureState object, which contains the state of the whole gesture (from starting the touch until releasing the finger). This can make your life a lot easier, since you don't have to calculate everything on your own.
If you don't need this gestureState or the properties provided by the gestureState objects are not sufficient for your use case, you could work directly with the Gesture Responder System. Otherwise I would recommend using PanResponder.
In my app, I have horizontal FlatList which is used for swiping between several sub-pages of a screen. This works great.
However, on one of the pages, I have a Slider component. On iOS it works fine, but on Android, the parent ScrollView of the FlatList seems to "steal" the swipe gesture. I am only able to adjust the Slider by clicking very precisely on its thin line, but I cannot adjust it by sliding.
What I need is something like one of these
A view that wraps the Slider component and stops swipe gestures from being propagated to the parent ScrollView
A way to make the FlatList/ScrollView not consume swipes directly on elements that responds to horizontal swipes themself
Somehow adjust the area of which the Slider component will eat the touches around it (it's very small and hard to hit directly). I already tried adding a hitSlop prop, with no luck.
Any suggestions for a solution are very appreciated :)
Check example code and result here.
https://snack.expo.io/#esbenvb/mad-yogurt
I try to use two PanResponder to handle multi-touch event. One PanResponder in charge of upper half screen, and one lower. The two PanResponders work fine as long as there only one finger touch the screen. But when I put two finger on the screen, only one PanResponder works. So I only know coordinate( movement) of one finger and have no idea what status of the other finger is.
I can confirm I have this behavior and was unable to get an array of 2 touches with PanResponder.
It seems other people reported the problem in the past: https://react-native.canny.io/feature-requests/p/panresponderonpanrespondermove-not-responding-for-pinch
I have a scrollView. Typical tableView Cell. I did things a lot on viewDidScroll.
viewDidScroll is called on 2 cases.
User scroll
Sometimes user have stop scrolling but the scrollview still scroll anyway due to momentum, bouncing, etc.
So how do I know if users are still touching the scrollView?
UIScrollView has a BOOL property named tracking that is YES while the scroll view has a touch and NO otherwise. In my testing, it is set to NO as soon as the touch ends, even if the view is decelerating (and still sending scrollViewDidScroll: to its delegate). This seems like exactly what you are asking for.
In my testing, the dragging property doesn't seem to become NO reliably while the view is decelerating after the touch ends.
The decelerating property is also unreliable in my testing. If I touch the scroll view while it is decelerating, decelerating remains YES even though the view has stopped scrolling.
The delegate's scrollViewWillBeginDragging: is called when user starts dragging and scrollViewDidEndDragging:willDecelerate: & scrollViewWillEndDragging:withVelocity:targetContentOffset:(iOS 5+ without paging enabled) is called when user lefts his/her fingers.
You may also want to check scrollViewWillBeginDecelerating: and scrollViewDidEndDecelerating:.
Ref: http://developer.apple.com/library/ios/#documentation/uikit/reference/uiscrollviewdelegate_protocol/Reference/UIScrollViewDelegate.html
Does anyone know if there is a way to show the keyboard in iOS without animating it? Or better yet, can you change the animation speed?
Thanks
The only way I know of, is pushing a view controller which has a view which is made first responder in -viewDidLoad. (viewWillAppear will probably do fine as well)
Pushing it without animation might get you a keyboard popping up without animation.
update too bad, it seems either the view animates into screen (modally or pushed on the navigation stack, with animated:YES) with the keyboard fixed, or the view comes up without animation (i.e. animated:NO) making the keyboard animate into screen again.