-
-
Notifications
You must be signed in to change notification settings - Fork 983
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
Allow two finger touchpad scrolling on iPadOS #1128
Allow two finger touchpad scrolling on iPadOS #1128
Conversation
This breaks CI. |
…tive-gesture-handler into touchpad-scrolling
I'm guessing it's because the XCode used in the CI is 10.2 (current is 11.7) and this flag requires iOS 13 (which should require XCode 11 to build). |
I finally bumped CI and if checks will pass I'll merge this one. |
One question though - should we do that by default? |
Good point. I've made it configurable and opt-in (through the property |
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.
Left some inline comments.
I pasted some test code into a description. I don't have access to the touchpad connected to the iPad, you please verify that it works with this PR? |
@jakub-gonet I've verified that the test code works - and of course the examples. Ready to merge? |
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.
LGMT, thanks for the patch.
## Description Adding support for touchpad in PanGestureHandler by setting `allowedScrollTypesMask` to `UIScrollTypeMaskAll` for all devices with iOS 13.4+. Important for iPads with Touchpads and should work with Mac Catalyst through the same API as well. As described in software-mansion#1100 - this covers the ipadOS part of that issue. ## Test plan Run on an iPad with touchpad. It's now possible to two-finger swipe to interact with the PanGestureHandler. ```jsx import React from 'react'; import { AppRegistry, SafeAreaView, Animated } from 'react-native'; import { PanGestureHandler, State } from 'react-native-gesture-handler'; const Example = () => { const translateX = new Animated.Value(0); const translateY = new Animated.Value(0); const lastOffset = { x: 0, y: 0 }; const onPanGestureEvent = Animated.event([ { nativeEvent: { translationX: translateX, translationY: translateY, }, }, ]); const onHandlerStateChange = ({ nativeEvent: { translationX, translationY, oldState }, }) => { if (oldState === State.ACTIVE) { // compensate a start of pan lastOffset.x += translationX; lastOffset.y += translationY; translateX.setOffset(lastOffset.x); translateY.setOffset(lastOffset.y); translateX.setValue(0); translateY.setValue(0); } }; return ( <SafeAreaView style={styles.container}> <PanGestureHandler onGestureEvent={onPanGestureEvent} onHandlerStateChange={onHandlerStateChange}> <Animated.View style={[ styles.rectangle, { transform: [{ translateX }, { translateY }], }, ]} /> </PanGestureHandler> </SafeAreaView> ); }; const styles = { container: { flex: 1, justifyContent: 'center', alignItems: 'center' }, rectangle: { backgroundColor: 'pink', width: 100, height: 100, }, }; AppRegistry.registerComponent('Example', () => Example); ``` Co-authored-by: Jakub Gonet <[email protected]>
Description
Adding support for touchpad in PanGestureHandler by setting
allowedScrollTypesMask
toUIScrollTypeMaskAll
for all devices with iOS 13.4+. Important for iPads with Touchpads and should work with Mac Catalyst through the same API as well. As described in #1100 - this covers the ipadOS part of that issue.Test plan
Run on an iPad with touchpad. It's now possible to two-finger swipe to interact with the PanGestureHandler.
Show code