-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[docs] Add platform badges #3975
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
Merged
Merged
Changes from 53 commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
a14db83
Fix edit link
m-bert 9e1f534
introduction
m-bert 54889bb
installation
m-bert 3e82cf8
Gesture detector
m-bert e005621
Reanimated interactions
m-bert 90b1aa4
Animated interactions
m-bert a5b73b3
Composition
m-bert 6c4aa0f
Merge branch 'main' into @mbert/docs-review
m-bert b2f97c5
State manager
m-bert 8cb20ab
Callbacks
m-bert 8f442f1
Quickstart
m-bert 12abfeb
Troubleshooting
m-bert 1094f92
Testing
m-bert d91e097
Fix callbacks flow chart
m-bert c503ea1
Pan
m-bert 31a8db3
Tap
m-bert b3efbbe
LongPress
m-bert d201b3e
Rotation
m-bert 62d0fe8
Pinch
m-bert 64aa192
Fling
m-bert 4667c7d
Hover
m-bert 5f40baf
Native
m-bert 800b37d
Manual
m-bert 004f919
Touch events
m-bert e8ddacc
Pinch typo
m-bert 128b226
HOOOOOOOOOOOOOOOOOOOOW?
m-bert cc1e783
Update packages/docs-gesture-handler/docs/guides/testing.md
m-bert d48e4ea
Update packages/docs-gesture-handler/docs/fundamentals/gesture-detect…
m-bert 9f1ec51
Overrides
m-bert 9b4aff8
Fix broken link
m-bert 0ce4f89
Merge branch 'main' into @mbert/docs-review
m-bert 1b48239
Pressable
m-bert e9e88a5
Swipeable
m-bert 5fcdc6c
Drawer
m-bert 6d909f3
Minor adjustments
m-bert 6563cdc
Update packages/docs-gesture-handler/docs/fundamentals/gesture-detect…
m-bert f3500a4
Update kotlin version
m-bert 9840339
Merge branch '@mbert/docs-review' of github.com:software-mansion/reac…
m-bert 3d706ec
Update packages/docs-gesture-handler/docs/fundamentals/state-manager.mdx
m-bert 2a877d9
Update packages/docs-gesture-handler/docs/fundamentals/state-manager.mdx
m-bert f927bf5
Remove ts block
m-bert 18e4350
Update packages/docs-gesture-handler/docs/gestures/use-native-gesture…
m-bert 8232dc8
Merge branch 'main' into @mbert/docs-review
m-bert 264a843
Merge branch '@mbert/docs-review' of github.com:software-mansion/reac…
m-bert 4fd4d8c
Rea and Ani
m-bert a09df73
Move examples to separate files
m-bert f94da57
Remove a
m-bert c9c429e
manualActivation
m-bert ca8179c
Merge branch 'main' into @mbert/docs-review
m-bert 788827a
Update packages/docs-gesture-handler/docs/fundamentals/installation.mdx
m-bert d247707
Merge branch '@mbert/docs-review' of github.com:software-mansion/reac…
m-bert 94526fd
Add other badges
m-bert 04f992e
Add badges to pages
m-bert 4daad27
Merge branch 'main' into @mbert/docs-badges
m-bert a997a49
Revert gesture-composition sidebar change
m-bert b6eead3
Copilot review
m-bert 8ba5b1c
Merge branch 'main' into @mbert/docs-badges
m-bert d52b0f9
Add badges to buttons
m-bert 79b7f52
Hover android
m-bert b45919e
Sort badges
m-bert b6efac4
Change android color
m-bert e15ee60
two finger trackpad web
m-bert 0cd3c28
Make badges case insensitive
m-bert 549b6a7
Merge branch 'main' into @mbert/docs-badges
m-bert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,133 +7,255 @@ sidebar_label: Pressable | |
| import useBaseUrl from '@docusaurus/useBaseUrl'; | ||
| import GifGallery from '@site/components/GifGallery'; | ||
|
|
||
| <GifGallery> | ||
| <img src={useBaseUrl('gifs/pressable.gif')} width="70%" /> | ||
| </GifGallery> | ||
| import HeaderWithBadge from '@site/src/components/HeaderWithBadge'; | ||
|
|
||
| :::info | ||
| This component is a drop-in replacement for the `Pressable` component. | ||
| ::: | ||
|
|
||
| `Pressable` is a component that can detect various stages of tap, press, and hover interactions on any of its children. | ||
| <GifGallery> | ||
| <img src={useBaseUrl('gifs/pressable.gif')} width="70%" /> | ||
| </GifGallery> | ||
|
|
||
| ### Usage: | ||
| `Pressable` is a component that can detect various stages of tap, press, and hover interactions on any of its children. | ||
|
|
||
| To use `Pressable`, import it in the following way: | ||
| To use `Pressable`, ensure that your app is wrapped in `GestureHandlerRootView` and import it as follows: | ||
|
|
||
| ```js | ||
| ```ts | ||
| import { Pressable } from 'react-native-gesture-handler'; | ||
| ``` | ||
|
|
||
| ## Properties | ||
|
|
||
| ### `children` | ||
| ### children | ||
|
|
||
| ```ts | ||
| children?: | ||
| | React.ReactNode | ||
| | ((state: PressableStateCallbackType) => React.ReactNode); | ||
| ``` | ||
|
|
||
| Either children or a render prop that receives a boolean reflecting whether the component is currently pressed. | ||
|
|
||
| ### style | ||
|
|
||
| ```ts | ||
| style?: | ||
| | StyleProp<ViewStyle> | ||
| | ((state: PressableStateCallbackType) => StyleProp<ViewStyle>); | ||
| ``` | ||
|
|
||
| Either view styles or a function that receives a boolean reflecting whether the component is currently pressed and returns view styles. | ||
|
|
||
| ### onPress | ||
|
|
||
| ```ts | ||
| onPress?: null | ((event: PressableEvent) => void); | ||
| ``` | ||
|
|
||
| Called after [`onPressOut`](#onpressout) when a single tap gesture is detected. Details about the event object can be found in the [PressableEvent](#pressableevent) section below. | ||
|
|
||
| ### onPressIn | ||
|
|
||
| ```ts | ||
| onPressIn?: null | ((event: PressableEvent) => void); | ||
| ``` | ||
|
|
||
| Called before `onPress` when a touch is engaged. Details about the event object can be found in the [PressableEvent](#pressableevent) section below. | ||
|
|
||
| ### onPressOut | ||
|
|
||
| ```ts | ||
| onPressOut?: null | ((event: PressableEvent) => void); | ||
| ``` | ||
|
|
||
| Called before `onPress` when a touch is released (before [`onPress`](#onpress)). Details about the event object can be found in the [PressableEvent](#pressableevent) section below. | ||
|
|
||
| either children or a render function that receives a boolean reflecting whether | ||
| the component is currently pressed. | ||
| ### onLongPress | ||
|
|
||
| ### `style` | ||
| ```ts | ||
| onLongPress?: null | ((event: PressableEvent) => void); | ||
| ``` | ||
|
|
||
| either view styles or a function that receives a boolean reflecting whether | ||
| the component is currently pressed and returns view styles. | ||
| Called immediately after pointer has been down for at least [`delayLongPress`](#delaylongpress) milliseconds. | ||
|
|
||
| ### `onPress` | ||
| After `onLongPress` has been called, [`onPressOut`](#onpressout) will be called as soon as the pointer is lifted and [`onPress`](#onpress) will not be called at all. | ||
|
|
||
| called after `onPressOut` when a single tap gesture is detected. | ||
| ### cancelable | ||
|
|
||
| ### `onPressIn` | ||
| ```ts | ||
| cancelable?: null | boolean; | ||
| ``` | ||
|
|
||
| called before `onPress` when a touch is engaged. | ||
| Whether a press gesture can be interrupted by a parent gesture such as a scroll event. Defaults to `true`. | ||
|
|
||
| ### `onPressOut` | ||
| <HeaderWithBadge platforms={['web']}> | ||
| ### onHoverIn | ||
| </HeaderWithBadge> | ||
|
|
||
| called before `onPress` when a touch is released. | ||
| ```ts | ||
| onHoverIn?: null | ((event: PressableEvent) => void); | ||
| ``` | ||
|
|
||
| ### `onLongPress` | ||
| Called when pointer is hovering over the element. | ||
|
|
||
| called immediately after pointer has been down for at least `delayLongPress` milliseconds (`500` ms by default). | ||
| <HeaderWithBadge platforms={['web']}> | ||
| ### onHoverOut | ||
| </HeaderWithBadge> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
|
|
||
| After `onLongPress` has been called, `onPressOut` will be called as soon as the pointer is lifted and `onPress` will not be called at all. | ||
| ```ts | ||
| onHoverOut?: null | ((event: PressableEvent) => void); | ||
| ``` | ||
|
|
||
| ### `cancelable` | ||
| Called when pointer stops hovering over the element. | ||
|
|
||
| whether a press gesture can be interrupted by a parent gesture such as a scroll event. Defaults to `true`. | ||
| <HeaderWithBadge platforms={['web']}> | ||
| ### delayHoverIn | ||
| </HeaderWithBadge> | ||
|
j-piasecki marked this conversation as resolved.
|
||
|
|
||
| ### `onHoverIn` (Web only) | ||
| ```ts | ||
| delayHoverIn?: number | null; | ||
| ``` | ||
|
|
||
| called when pointer is hovering over the element. | ||
| Duration to wait after hover in before calling `onHoverIn`. | ||
|
|
||
| ### `onHoverOut` (Web only) | ||
| <HeaderWithBadge platforms={['web']}> | ||
| ### delayHoverOut | ||
| </HeaderWithBadge> | ||
|
j-piasecki marked this conversation as resolved.
|
||
|
|
||
| called when pointer stops hovering over the element. | ||
| ```ts | ||
| delayHoverOut?: number | null; | ||
| ``` | ||
|
|
||
| ### `delayHoverIn` (Web only) | ||
| Duration to wait after hover out before calling `onHoverOut`. | ||
|
|
||
| duration to wait after hover in before calling `onHoverIn`. | ||
| ### delayLongPress | ||
|
|
||
| ### `delayHoverOut` (Web only) | ||
| ```ts | ||
| delayLongPress?: null | number; | ||
| ``` | ||
|
|
||
| duration to wait after hover out before calling `onHoverOut`. | ||
| Duration (in milliseconds) from `onPressIn` before `onLongPress` is called. Default value is `500` ms. | ||
|
|
||
| ### `delayLongPress` | ||
| ### disabled | ||
|
|
||
| duration (in milliseconds) from `onPressIn` before `onLongPress` is called. | ||
| ```ts | ||
| disabled?: null | boolean; | ||
| ``` | ||
|
|
||
| ### `disabled` | ||
| Whether the `Pressable` behavior is disabled. | ||
|
|
||
| whether the `Pressable` behavior is disabled. | ||
| <HeaderWithBadge platforms={['android', 'iOS']}> | ||
| ### hitSlop | ||
| </HeaderWithBadge> | ||
|
|
||
| ### `hitSlop` (Android & iOS only) | ||
| ```ts | ||
| hitSlop?: null | Insets | number; | ||
| ``` | ||
|
|
||
| additional distance outside of the view in which a press is detected and `onPressIn` is triggered. | ||
| Additional distance outside of the view in which a press is detected and [`onPressIn`](#onpressin) is triggered. | ||
|
|
||
| Accepts values of type `number` or [`Rect`](https://reactnative.dev/docs/rect) | ||
| The `Insets` type is essentially the same as [`Rect`](https://reactnative.dev/docs/rect). | ||
|
|
||
| ### `pressRetentionOffset` (Android & iOS only) | ||
| <HeaderWithBadge platforms={['android', 'iOS']}> | ||
| ### pressRetentionOffset | ||
| </HeaderWithBadge> | ||
|
|
||
| additional distance outside of the view (or `hitSlop` if present) in which a touch is considered a | ||
| press before `onPressOut` is triggered. | ||
| ```ts | ||
| pressRetentionOffset?: null | Insets | number; | ||
| ``` | ||
|
|
||
| Accepts values of type `number` or [`Rect`](https://reactnative.dev/docs/rect) | ||
| Additional distance outside of the view (or [`hitSlop`](#hitslop) if present) in which a touch is considered a | ||
| press before [`onPressOut`](#onpressout) is triggered. | ||
|
|
||
| ### `android_disableSound` (Android only) | ||
| The `Insets` type is essentially the same as [`Rect`](https://reactnative.dev/docs/rect). | ||
|
|
||
| if `true`, doesn't play system sound on touch. | ||
| <HeaderWithBadge platforms={['android']}> | ||
| ### android_disableSound | ||
| </HeaderWithBadge> | ||
|
|
||
| ### `android_ripple` (Android only) | ||
| ```ts | ||
| android_disableSound?: null | boolean; | ||
| ``` | ||
|
|
||
| enables the Android ripple effect and configures its color, radius and other parameters. | ||
| If `true`, doesn't play system sound on touch. | ||
|
|
||
| Accepts values of type [`RippleConfig`](https://reactnative.dev/docs/pressable#rippleconfig) | ||
| <HeaderWithBadge platforms={['android']}> | ||
| ### android_ripple | ||
| </HeaderWithBadge> | ||
|
|
||
| ### `testOnly_pressed` | ||
| ```ts | ||
| android_ripple?: null | PressableAndroidRippleConfig; | ||
| ``` | ||
|
|
||
| used only for documentation or testing (e.g. snapshot testing). | ||
| Enables the Android [ripple](https://developer.android.com/reference/android/graphics/drawable/RippleDrawable) effect and configures its color, radius and other parameters. | ||
|
|
||
| ### `unstable_pressDelay` | ||
| Accepts values of type [`RippleConfig`](https://reactnative.dev/docs/pressable#rippleconfig). | ||
|
|
||
| duration (in milliseconds) to wait after press down before calling `onPressIn`. | ||
| ### testOnly_pressed | ||
|
|
||
| ### Example: | ||
| ```ts | ||
| testOnly_pressed?: null | boolean; | ||
| ``` | ||
|
|
||
| See the full [pressable example](https://github.com/software-mansion/react-native-gesture-handler/blob/main/apps/common-app/src/new_api/pressable/index.tsx) from `GestureHandler` example app. | ||
| Used only for documentation or testing (e.g. snapshot testing). | ||
|
|
||
| import GestureStateFlowExample from '@site/src/examples/GestureStateFlowExample'; | ||
| ### unstable_pressDelay | ||
|
|
||
| ```js | ||
| ```ts | ||
| unstable_pressDelay?: number | undefined; | ||
| ``` | ||
|
|
||
| Duration (in milliseconds) to wait after press down before calling [`onPressIn`](#onpressin). | ||
|
|
||
| ## PressableEvent | ||
|
|
||
| All `Pressable` callbacks receive an event object as a parameter, which is of type `PressableEvent` and has the following structure: | ||
|
|
||
| ```ts | ||
| export type PressableEvent = { nativeEvent: InnerPressableEvent }; | ||
|
|
||
| export type InnerPressableEvent = { | ||
| changedTouches: InnerPressableEvent[]; | ||
| identifier: number; | ||
| locationX: number; | ||
| locationY: number; | ||
| pageX: number; | ||
| pageY: number; | ||
| target: number; | ||
| timestamp: number; | ||
| touches: InnerPressableEvent[]; | ||
| force?: number; | ||
| }; | ||
| ``` | ||
|
|
||
| ## Example | ||
|
|
||
| See the full example in [Gesture Handler repository](https://github.com/software-mansion/react-native-gesture-handler/blob/main/apps/common-app/src/legacy/v2_api/pressable/index.tsx). | ||
|
|
||
| <CollapsibleCode | ||
| label="Show full example" | ||
| expandedLabel="Hide full example" | ||
| lineBounds={[5, 20]} | ||
| src={` | ||
| import { View, Text, StyleSheet } from 'react-native'; | ||
| import { Pressable } from 'react-native-gesture-handler'; | ||
| import { | ||
| GestureHandlerRootView, | ||
| Pressable, | ||
| } from 'react-native-gesture-handler'; | ||
|
|
||
| export default function Example() { | ||
| return ( | ||
| <Pressable | ||
| style={({ pressed }) => (pressed ? styles.highlight : styles.pressable)} | ||
| hitSlop={20} | ||
| pressRetentionOffset={20}> | ||
| <View style={styles.textWrapper}> | ||
| <Text style={styles.text}>Pressable!</Text> | ||
| </View> | ||
| </Pressable> | ||
| <GestureHandlerRootView> | ||
| <Pressable | ||
| style={({ pressed }) => (pressed ? styles.highlight : styles.pressable)} | ||
| hitSlop={20} | ||
| pressRetentionOffset={20}> | ||
| <View style={styles.textWrapper}> | ||
| <Text style={styles.text}>Pressable!</Text> | ||
| </View> | ||
| </Pressable> | ||
| </GestureHandlerRootView> | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -159,4 +281,4 @@ const styles = StyleSheet.create({ | |
| color: 'black', | ||
| }, | ||
| }); | ||
| ``` | ||
| `}/> | ||
Oops, something went wrong.
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.
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.
Doesn't this also work on native when using mouse/stylus?
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 also thought about it. I'm not sure about iOS, I can test it on android though.