You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: Documentation of some new props and features (#356)
## Description
This PR:
- adds new `reorderTriggerOrigin` and `overflow` props to docs
- improves callbacks documentation and adds information about new
feature - worklet callbacks
- Updates the type of `DropIndicatorComponentProps` in docs to the
correct type
Copy file name to clipboardExpand all lines: packages/docs/docs/flex/props.mdx
+99-29Lines changed: 99 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Whenever `Animatable<T>` is used, it refers to the following type definition:
11
11
typeAnimatable<T> =SharedValue<T> |T;
12
12
```
13
13
14
-
This means that properties of type `Animatable<T>` can accept either:
14
+
This means that properties of type `Animatable<T>` can accept either of the following:
15
15
16
16
- a Reanimated **Shared Value** (`SharedValue<T>`)
17
17
- a **static value** of type `T`
@@ -268,7 +268,7 @@ This may sometimes cause **performance issues** as it requires layout recalculat
268
268
269
269
---
270
270
271
-
## Item Drag Settings
271
+
## Item Drag
272
272
273
273
### overDrag
274
274
@@ -325,6 +325,42 @@ The maximum distance (in pixels) the finger can move from the touch start positi
325
325
326
326
---
327
327
328
+
## Reordering
329
+
330
+
### strategy
331
+
332
+
Controls how items **are reordered** while the **active item** is being **dragged around**.
333
+
334
+
| type | default | required |
335
+
| ---------------------- | -------- | -------- |
336
+
|`SortableFlexStrategy`| 'insert' | NO |
337
+
338
+
-`'insert'` - items are reordered by inserting the active item at the target position and moving all items between the active item and the target position
{/* TODO: Add link to docs page explaining how to use SortableFlexStrategyFactory */}
348
+
349
+
</details>
350
+
351
+
### reorderTriggerOrigin
352
+
353
+
Determines position of the reordering trigger point. If that point enters the area of a different item than the current one, the reordering will be triggered.
354
+
355
+
| type | default | required |
356
+
| --------------------- | ---------- | -------- |
357
+
|`'center' \| 'touch'`|`'center'`| NO |
358
+
359
+
-`'center'` - reordering will be triggered when the center of the active item enters the area of a different item
360
+
-`'touch'` - reordering will be triggered when the touch point enters the area of a different item
361
+
362
+
---
363
+
328
364
## Active Item Decoration
329
365
330
366
All active item decoration settings are applied when the **item becomes active** (when drag gesture starts being handled).
@@ -536,11 +572,17 @@ Component to use as the drop indicator. It gives a **full control** over the dro
536
572
537
573
```tsx
538
574
typeDropIndicatorComponentProps= {
539
-
activationProgress:SharedValue<number>;
540
-
touchedItemKey:SharedValue<null|string>;
575
+
/** Progress of the active item animation (from 0 to 1) */
576
+
activeAnimationProgress:SharedValue<number>;
577
+
/** Key of the currently dragged item, or null if no item is being dragged */
578
+
activeItemKey:SharedValue<null|string>;
579
+
/** Current index where the dragged item would be dropped */
541
580
dropIndex:SharedValue<number>;
581
+
/** Current position where the item would be dropped */
542
582
dropPosition:SharedValue<Vector>;
583
+
/** Array of item keys in their current order */
543
584
orderedItemKeys:SharedValue<Array<string>>;
585
+
/** Style to be applied to the drop indicator */
544
586
style:ViewStyle;
545
587
};
546
588
```
@@ -553,13 +595,9 @@ type DropIndicatorComponentProps = {
553
595
554
596
Layout animations control how items animate when their positions change and when they are added or removed from the flex container.
555
597
556
-
:::note
557
-
558
598
- Item **entering** animations are **not** triggered during the **initial render** of the flex container
559
599
- Item **exiting** animations are **not** triggered when the **entire flex container is unmounted**
560
600
561
-
:::
562
-
563
601
:::warning Warning (Web)
564
602
565
603
There are some **differences** in the **layout animations** implementation on **Web**:
@@ -676,6 +714,41 @@ import reorderVideo from '@site/static/video/flex-layout-transition-mode-reorder
676
714
677
715
## Callbacks
678
716
717
+
:::tip Performance Recommendation
718
+
Use **worklet functions** for callbacks to run directly on the UI thread and avoid thread jumping overhead.
719
+
:::
720
+
721
+
All callbacks accept two types of functions:
722
+
723
+
1.**Worklet Functions** (Recommended)
724
+
725
+
- To mark a function as worklet, you have to add `'worklet'` directive at the start of the function body
For more information about worklets refer to the [Reanimated documentation](https://docs.swmansion.com/react-native-reanimated/docs/guides/worklets/).
750
+
:::
751
+
679
752
### onDragStart
680
753
681
754
Called when the drag gesture starts.
@@ -753,6 +826,12 @@ type OrderChangeParams = {
753
826
754
827
</details>
755
828
829
+
:::warning
830
+
831
+
**Don't use** this callback to update items order in state because it's called **frequently** during dragging. Use `onDragEnd` for **state updates** instead.
832
+
833
+
:::
834
+
756
835
---
757
836
758
837
### onDragMove
@@ -782,27 +861,6 @@ type DragMoveParams = {
782
861
783
862
## Other Settings
784
863
785
-
### strategy
786
-
787
-
Controls how items **are reordered** while the **active item** is being **dragged around**.
Enables debug mode, which shows additional views helpful for debugging. This property is intended for the library **developers** and is not recommended for the library **users**.
843
911
912
+
Debug mode has no effect in production builds and can be used to debug the library only in the development environment.
0 commit comments