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
4.[Get notified on drag events](#4-get-notified-on-drag-events)
29
-
30
48
### 1. Create page state variable
31
49
32
50
In this example, we have two images of a shelf: one with empty space for one plant and another
@@ -57,10 +75,42 @@ In this example, the draggable items are a plant, a spoon, and a football. Let's
57
75
2. Inside the **Draggable** widget, you can add any widget as a child widget. For this example, we use the **Image** widget.
58
76
3. To add data to draggable widgets, select the **Draggable widget > Properties Panel > Draggable Properties >** specify the **Type** of the data and its **Value**.
The Draggable widget also provides you with various drag events (as [**Action Triggers**](../../../control-flow/functions/action-triggers.md)) that you might want to use to customize the drag experience. These include:
63
107
108
+
-**On Drag Started**: Gets triggered when the user initiates a drag operation.
109
+
-**On Drag Update**: Gets triggered when the drag is currently in progress, allowing you to track its movement or update other UI elements accordingly.
110
+
-**On Drag Completed**: Gets triggered when the user successfully drags and drops the widget into [**DragTarget**](#3-add-dragtarget-widget) widget.
111
+
-**On Drag Cancelled**: Gets triggered when the drag operation is aborted, such as when the user releases the widget outside a **DragTarget** or the DragTarget rejects the widget.
112
+
-**On Drag End**: Gets triggered when the drag operation finishes, regardless of whether it was completed or cancelled.
113
+
:::
64
114
65
115
### 3. Add DragTarget widget
66
116
@@ -72,10 +122,33 @@ Let's see how to add DragTarget widget:
72
122
2. Inside the **DragTarget** widget, add a [**Container**](../../widgets/basic-widgets/container.md) widget, preferably of the same size as the image, and set its background color to transparent. This will serve as the drop zone for draggable items.
73
123
3. Now, you need to specify the type of data this target will receive. To do so select the **DragTarget widget > Properties Panel > Draggable Properties >** specify the **Type** of the data. This is crucial for ensuring that only the correct items can be dropped on the target.
@@ -106,19 +179,35 @@ and click **Open**. This will open an **Action Flow Editor** in a new popup wind
106
179
5. From the **set variable** menu, select **Drag Target > Dragged Data**. This captures the data of the draggable item that we added in [step 2](#2-add-draggable-widgets).
107
180
8. Check if the captured data matches the expected item, i.e., plant.
108
181
11. In the **TRUE** branch, you can add a [snackbar message](../../pages/page-elements.md#snackbar) and [update](../../pages/page-lifecycle.md#page-state) the `isShelfFull` variable to True. This will create an effect like the user has actually dragged and dropped the item onto the shelf.
109
-
3. Now, select the **On Drag Exit** andadd an action to [update](../../pages/page-lifecycle.md#page-state) the `isShelfFull` variable to False. This ensures that if the user decides not to drop the item and moves it away, the shelf image reverts to the empty one.
3. Now, select the **On Drag Exit** andadd an action to [update](../../pages/page-lifecycle.md#page-state) the `isShelfFull` variable to False. This ensures that if the user decides not to drop the item and moves it away, the shelf image reverts to the empty one.
0 commit comments