-
-
Notifications
You must be signed in to change notification settings - Fork 1k
[docs] Redirects #3976
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
[docs] Redirects #3976
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dab49b8
Redirects
m-bert 878641a
Merge branch 'main' into @mbert/docs-redirects
m-bert d11dd8a
Bring back old docs
m-bert 643477b
Remove unused import
m-bert 4e7d416
Merge branch 'main' into @mbert/docs-redirects
m-bert 4b515f3
Point to legacy-docs
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
7 changes: 7 additions & 0 deletions
7
packages/docs-gesture-handler/docs/legacy-gestures/_category_.json
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 |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "label": "Gesture Handler 2", | ||
| "position": 4, | ||
| "link": { | ||
| "type": "generated-index" | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
...sture-handler/docs/legacy-gestures/_shared/base-continuous-gesture-callbacks.md
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 |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| ### Callbacks common to all continuous gestures: | ||
|
|
||
| ### `onUpdate(callback)` | ||
|
|
||
| Set the callback that is being called every time the gesture receives an update while it's active. | ||
|
|
||
| ### `onChange(callback)` | ||
|
|
||
| Set the callback that is being called every time the gesture receives an update while it's active. This callback will receive information about change in value in relation to the last received event. | ||
5 changes: 5 additions & 0 deletions
5
...-gesture-handler/docs/legacy-gestures/_shared/base-continuous-gesture-config.md
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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| ### Properties common to all continuous gestures: | ||
|
|
||
| ### `manualActivation(value: boolean)` | ||
|
|
||
| When `true` the handler will not activate by itself even if its activation criteria are met. Instead you can manipulate its state using [state manager](/docs/2.x/gestures/state-manager/). |
33 changes: 33 additions & 0 deletions
33
...ges/docs-gesture-handler/docs/legacy-gestures/_shared/base-gesture-callbacks.md
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 |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| ### Callbacks common to all gestures: | ||
|
|
||
| ### `onBegin(callback)` | ||
|
|
||
| Set the callback that is being called when given gesture handler starts receiving touches. At the moment of this callback the handler is not yet in an active state and we don't know yet if it will recognize the gesture at all. | ||
|
|
||
| ### `onStart(callback)` | ||
|
|
||
| Set the callback that is being called when the gesture is recognized by the handler and it transitions to the active state. | ||
|
|
||
| ### `onEnd(callback)` | ||
|
|
||
| Set the callback that is being called when the gesture that was recognized by the handler finishes. It will be called only if the handler was previously in the active state. | ||
|
|
||
| ### `onFinalize(callback)` | ||
|
|
||
| Set the callback that is being called when the handler finalizes handling gesture - the gesture was recognized and has finished or it failed to recognize. | ||
|
|
||
| ### `onTouchesDown(callback)` | ||
|
|
||
| Set the `onTouchesDown` callback which is called every time a finger is placed on the screen. | ||
|
|
||
| ### `onTouchesMove(callback)` | ||
|
|
||
| Set the `onTouchesMove` callback which is called every time a finger is moved on the screen. | ||
|
|
||
| ### `onTouchesUp(callback)` | ||
|
|
||
| Set the `onTouchesUp` callback which is called every time a finger is lifted from the screen. | ||
|
|
||
| ### `onTouchesCancelled(callback)` | ||
|
|
||
| Set the `onTouchesCancelled` callback which is called every time a finger stops being tracked, for example when the gesture finishes. |
68 changes: 68 additions & 0 deletions
68
packages/docs-gesture-handler/docs/legacy-gestures/_shared/base-gesture-config.md
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 |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| ### Properties common to all gestures: | ||
|
|
||
| ### `enabled(value: boolean)` | ||
|
|
||
| Indicates whether the given handler should be analyzing stream of touch events or not. | ||
| When set to `false` we can be sure that the handler's state will **never** become [`ACTIVE`](/docs/2.x/fundamentals/states-events#active). | ||
| If the value gets updated while the handler already started recognizing a gesture, then the handler's state it will immediately change to [`FAILED`](/docs/2.x/fundamentals/states-events#failed) or [`CANCELLED`](/docs/2.x/fundamentals/states-events#cancelled) (depending on its current state). | ||
| Default value is `true`. | ||
|
|
||
| ### `shouldCancelWhenOutside(value: boolean)` | ||
|
|
||
| When `true` the handler will [cancel](/docs/2.x/fundamentals/states-events#cancelled) or [fail](/docs/2.x/fundamentals/states-events#failed) recognition (depending on its current state) whenever the finger leaves the area of the connected view. | ||
| Default value of this property is different depending on the handler type. | ||
| Most handlers' `shouldCancelWhenOutside` property defaults to `false` except for the [`LongPressGesture`](/docs/2.x/gestures/long-press-gesture) and [`TapGesture`](/docs/2.x/gestures/tap-gesture) which default to `true`. | ||
|
|
||
| ### `hitSlop(settings)` | ||
|
|
||
| This parameter enables control over what part of the connected view area can be used to [begin](/docs/2.x/fundamentals/states-events#began) recognizing the gesture. | ||
| When a negative number is provided the bounds of the view will reduce the area by the given number of points in each of the sides evenly. | ||
|
|
||
| Instead you can pass an object to specify how each boundary side should be reduced by providing different number of points for `left`, `right`, `top` or `bottom` sides. | ||
| You can alternatively provide `horizontal` or `vertical` instead of specifying directly `left`, `right` or `top` and `bottom`. | ||
| Finally, the object can also take `width` and `height` attributes. | ||
| When `width` is set it is only allow to specify one of the sides `right` or `left`. | ||
| Similarly when `height` is provided only `top` or `bottom` can be set. | ||
| Specifying `width` or `height` is useful if we only want the gesture to activate on the edge of the view. In which case for example we can set `left: 0` and `width: 20` which would make it possible for the gesture to be recognize when started no more than 20 points from the left edge. | ||
|
|
||
| **IMPORTANT:** Note that this parameter is primarily designed to reduce the area where gesture can activate. Hence it is only supported for all the values (except `width` and `height`) to be non positive (0 or lower). Although on Android it is supported for the values to also be positive and therefore allow to expand beyond view bounds but not further than the parent view bounds. To achieve this effect on both platforms you can use React Native's View [hitSlop](https://reactnative.dev/docs/view.html#hitslop) property. | ||
|
|
||
| ### `withRef(ref)` | ||
|
|
||
| Sets a ref to the gesture object, allowing for interoperability with the old | ||
| API. | ||
|
|
||
| ### `withTestId(testID)` | ||
|
|
||
| Sets a `testID` property for gesture object, allowing for querying for it in tests. | ||
|
|
||
| ### `cancelsTouchesInView(value)` (**iOS only**) | ||
|
|
||
| Accepts a boolean value. | ||
| When `true`, the gesture will cancel touches for native UI components (`UIButton`, `UISwitch`, etc) it's attached to when it becomes [`ACTIVE`](/docs/2.x/fundamentals/states-events#active). | ||
| Default value is `true`. | ||
|
|
||
| ### `runOnJS(value: boolean)` | ||
|
|
||
| When `react-native-reanimated` is installed, the callbacks passed to the gestures are automatically workletized and run on the UI thread when called. This option allows for changing this behavior: when `true`, all the callbacks will be run on the JS thread instead of the UI thread, regardless of whether they are worklets or not. | ||
| Defaults to `false`. | ||
|
|
||
| ### `simultaneousWithExternalGesture(otherGesture1, otherGesture2, ...)` | ||
|
|
||
| Adds a gesture that should be recognized simultaneously with this one. | ||
|
|
||
| **IMPORTANT:** Note that this method only marks the relation between gestures, without [composing them](/docs/2.x/fundamentals/gesture-composition). [`GestureDetector`](/docs/2.x/gestures/gesture-detector) will not recognize the `otherGestures` and it needs to be added to another detector in order to be recognized. | ||
|
|
||
| ### `requireExternalGestureToFail(otherGesture1, otherGesture2, ...)` | ||
|
|
||
| Adds a relation requiring another gesture to fail, before this one can activate. | ||
|
|
||
| ### `blocksExternalGesture(otherGesture1, otherGesture2, ...)` | ||
|
|
||
| Adds a relation that makes other gestures wait with activation until this gesture fails (or doesn't start at all). | ||
|
|
||
| **IMPORTANT:** Note that this method only marks the relation between gestures, without [composing them](/docs/2.x/fundamentals/gesture-composition).[`GestureDetector`](/docs/2.x/gestures/gesture-detector) will not recognize the `otherGestures` and it needs to be added to another detector in order to be recognized. | ||
|
|
||
| ### `activeCursor(value)` (Web only) | ||
|
|
||
| This parameter allows to specify which cursor should be used when gesture activates. Supports all CSS cursor values (e.g. `"grab"`, `"zoom-in"`). Default value is set to `"auto"`. |
19 changes: 19 additions & 0 deletions
19
...es/docs-gesture-handler/docs/legacy-gestures/_shared/base-gesture-event-data.md
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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| ### Event attributes common to all gestures: | ||
|
|
||
| ### `state` | ||
|
|
||
| Current [state](/docs/2.x/fundamentals/states-events) of the handler. Expressed as one of the constants exported under `State` object by the library. | ||
|
|
||
| ### `numberOfPointers` | ||
|
|
||
| Represents the number of pointers (fingers) currently placed on the screen. | ||
|
|
||
| ### `pointerType` | ||
|
|
||
| Indicates the type of pointer device in use. This value is represented by the `PointerType` enum, which includes the following fields: | ||
|
|
||
| - `TOUCH` - represents finger | ||
| - `STYLUS` - represents stylus or digital pen | ||
| - `MOUSE` - represents computer mouse | ||
| - `KEY` - represents keyboard | ||
| - `OTHER` - represents unknown device type that is not relevant |
19 changes: 19 additions & 0 deletions
19
...cs-gesture-handler/docs/legacy-gestures/_shared/gesture-detector-functional1.md
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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| ```jsx | ||
| export default function Example() { | ||
| const tap = Gesture.Tap().onStart(() => { | ||
| console.log('tap'); | ||
| }); | ||
|
|
||
| return ( | ||
| <GestureDetector gesture={tap}> | ||
| <FunctionalComponent> | ||
| <View style={styles.box} /> | ||
| </FunctionalComponent> | ||
| </GestureDetector> | ||
| ); | ||
| } | ||
|
|
||
| function FunctionalComponent(props) { | ||
| return <View collapsable={false}>{props.children}</View>; | ||
| } | ||
| ``` |
3 changes: 3 additions & 0 deletions
3
packages/docs-gesture-handler/docs/legacy-gestures/_shared/v2-info.md
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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| :::warning | ||
| Heads up! This page covers the old builder-based API from Gesture Handler 2. We recommend checking out the newer hook-based API from Gesture Handler 3. | ||
| ::: |
32 changes: 32 additions & 0 deletions
32
packages/docs-gesture-handler/docs/legacy-gestures/composed-gestures.md
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 |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| --- | ||
| id: composed-gestures | ||
| title: Composed gestures | ||
| sidebar_label: Composed gestures | ||
| sidebar_position: 13 | ||
| --- | ||
|
|
||
| import OldAPIInfo from './\_shared/v2-info.md' | ||
|
|
||
| <OldAPIInfo /> | ||
|
|
||
| Composed gestures (`Race`, `Simultaneous`, `Exclusive`) provide a simple way of building relations between gestures. See [Gesture Composition](/docs/2.x/fundamentals/gesture-composition) for more details. | ||
|
|
||
| ## Reference | ||
|
|
||
| ```jsx | ||
| import { GestureDetector, Gesture } from 'react-native-gesture-handler'; | ||
|
|
||
| function App() { | ||
| const pan = Gesture.Pan(); | ||
| const longPress = Gesture.LongPress(); | ||
|
|
||
| // highlight-next-line | ||
| const composed = Gesture.Race(pan, longPress); | ||
|
|
||
| return ( | ||
| <GestureDetector gesture={composed}> | ||
| <Animated.View /> | ||
| </GestureDetector> | ||
| ); | ||
| } | ||
| ``` |
157 changes: 157 additions & 0 deletions
157
packages/docs-gesture-handler/docs/legacy-gestures/fling-gesture.md
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 |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| --- | ||
| id: fling-gesture | ||
| title: Fling gesture | ||
| sidebar_label: Fling gesture | ||
| sidebar_position: 7 | ||
| --- | ||
|
|
||
| import { vanishOnMobile, appearOnMobile, webContainer } from '@site/src/utils/getGestureStyles'; | ||
|
|
||
| import useBaseUrl from '@docusaurus/useBaseUrl'; | ||
|
|
||
| import FlingGestureBasic from '@site/static/examples/FlingGestureBasic'; | ||
| import FlingGestureBasicSrc from '!!raw-loader!@site/static/examples/FlingGestureBasicSrc'; | ||
|
|
||
| import OldAPIInfo from './\_shared/v2-info.md' | ||
|
|
||
| <OldAPIInfo /> | ||
|
|
||
| <div className={webContainer}> | ||
| <div className={vanishOnMobile} style={{ display: 'flex', justifyContent: 'center', maxWidth: 360 }}> | ||
| <video playsInline autoPlay muted loop style={{maxWidth: 360}}> | ||
| <source src={useBaseUrl("/video/fling.mp4")} type="video/mp4"/> | ||
| </video> | ||
| </div> | ||
| <InteractiveExample | ||
| component={<FlingGestureBasic/>} | ||
| src={FlingGestureBasicSrc} | ||
| disableMarginBottom={true} | ||
| /> | ||
| </div> | ||
|
|
||
| import BaseEventData from './\_shared/base-gesture-event-data.md'; | ||
| import BaseEventConfig from './\_shared/base-gesture-config.md'; | ||
| import BaseEventCallbacks from './\_shared/base-gesture-callbacks.md'; | ||
|
|
||
| A discrete gesture that activates when the movement is sufficiently long and fast. | ||
| Gesture gets [ACTIVE](/docs/2.x/fundamentals/states-events#active) when movement is sufficiently long and it does not take too much time. | ||
| When gesture gets activated it will turn into [END](/docs/2.x/fundamentals/states-events#end) state when finger is released. | ||
| The gesture will fail to recognize if the finger is lifted before being activated. | ||
|
|
||
| <div className={appearOnMobile} style={{ display: 'flex', justifyContent: 'center' }}> | ||
| <video playsInline autoPlay muted loop style={{maxWidth: 360}}> | ||
| <source src={useBaseUrl("/video/fling.mp4")} type="video/mp4"/> | ||
| </video> | ||
| </div> | ||
|
|
||
| <samp id="FlingGestureBasicSrc">Fling Gesture</samp> | ||
|
|
||
| ## Example | ||
|
|
||
| ```jsx | ||
| import { StyleSheet } from 'react-native'; | ||
| import { | ||
| Gesture, | ||
| GestureDetector, | ||
| Directions, | ||
| } from 'react-native-gesture-handler'; | ||
| import Animated, { | ||
| useSharedValue, | ||
| useAnimatedStyle, | ||
| withTiming, | ||
| } from 'react-native-reanimated'; | ||
|
|
||
| export default function App() { | ||
| const position = useSharedValue(0); | ||
| // highlight-next-line | ||
| const flingGesture = Gesture.Fling() | ||
| .direction(Directions.RIGHT) | ||
| .onStart((e) => { | ||
| position.value = withTiming(position.value + 10, { duration: 100 }); | ||
| }); | ||
|
|
||
| const animatedStyle = useAnimatedStyle(() => ({ | ||
| transform: [{ translateX: position.value }], | ||
| })); | ||
|
|
||
| return ( | ||
| <GestureDetector gesture={flingGesture}> | ||
| <Animated.View style={[styles.box, animatedStyle]} /> | ||
| </GestureDetector> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| box: { | ||
| height: 120, | ||
| width: 120, | ||
| backgroundColor: '#b58df1', | ||
| borderRadius: 20, | ||
| marginBottom: 30, | ||
| }, | ||
| }); | ||
| ``` | ||
|
|
||
| ## Config | ||
|
|
||
| ### Properties specific to `FlingGesture`: | ||
|
|
||
| ### `direction(value: Directions)` | ||
|
|
||
| Expressed allowed direction of movement. Expected values are exported as constants in the `Directions` object. It's possible to pass one or many directions in one parameter: | ||
|
|
||
| ```js | ||
| import { Directions } from 'react-native-gesture-handler'; | ||
| fling.direction(Directions.RIGHT | Directions.LEFT); | ||
| ``` | ||
|
|
||
| or | ||
|
|
||
| ```js | ||
| fling.direction(Directions.DOWN); | ||
| ``` | ||
|
|
||
| ### `numberOfPointers(value: number)` | ||
|
|
||
| Determine exact number of points required to handle the fling gesture. | ||
|
|
||
| ### `mouseButton(value: MouseButton)` (Web & Android only) | ||
|
|
||
| Allows users to choose which mouse button should handler respond to. The enum `MouseButton` consists of the following predefined fields: | ||
|
|
||
| - `LEFT` | ||
| - `RIGHT` | ||
| - `MIDDLE` | ||
| - `BUTTON_4` | ||
| - `BUTTON_5` | ||
| - `ALL` | ||
|
|
||
| Arguments can be combined using `|` operator, e.g. `mouseButton(MouseButton.LEFT | MouseButton.RIGHT)`. Default value is set to `MouseButton.LEFT`. | ||
|
|
||
| <BaseEventConfig /> | ||
|
|
||
| ## Callbacks | ||
|
|
||
| <BaseEventCallbacks /> | ||
|
|
||
| ## Event data | ||
|
|
||
| ### Event attributes specific to `FlingGesture`: | ||
|
|
||
| ### `x` | ||
|
|
||
| X coordinate of the current position of the pointer (finger or a leading pointer when there are multiple fingers placed) relative to the view attached to the [`GestureDetector`](./gesture-detector.md). Expressed in point units. | ||
|
|
||
| ### `y` | ||
|
|
||
| Y coordinate of the current position of the pointer (finger or a leading pointer when there are multiple fingers placed) relative to the view attached to the [`GestureDetector`](./gesture-detector.md). Expressed in point units. | ||
|
|
||
| ### `absoluteX` | ||
|
|
||
| X coordinate of the current position of the pointer (finger or a leading pointer when there are multiple fingers placed) relative to the window. The value is expressed in point units. It is recommended to use it instead of [`x`](#x) in cases when the original view can be transformed as an effect of the gesture. | ||
|
|
||
| ### `absoluteY` | ||
|
|
||
| Y coordinate of the current position of the pointer (finger or a leading pointer when there are multiple fingers placed) relative to the window. The value is expressed in point units. It is recommended to use it instead of [`y`](#y) in cases when the original view can be transformed as an effect of the gesture. | ||
|
|
||
| <BaseEventData /> |
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.
Uh oh!
There was an error while loading. Please reload this page.