Skip to content

Commit dc1311f

Browse files
committed
docs(reorder): update event handling descriptions and add logs
1 parent 15db739 commit dc1311f

File tree

13 files changed

+53
-1
lines changed

13 files changed

+53
-1
lines changed

docs/api/reorder.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,22 @@ import UpdatingData from '@site/static/usage/v8/reorder/updating-data/index.md';
7777

7878
### Using `ionReorderStart` and `ionReorderEnd`
7979

80+
The `ionReorderStart` event is emitted when the user begins a reorder gesture. This event fires when the user taps and holds an item, before any movement occurs. This is useful for preparing the UI for the reorder operation, such as hiding certain elements or updating the visual state of items. For example, icons in list items can be hidden while they are being dragged and shown again when the reorder is complete.
81+
82+
The `ionReorderEnd` event is emitted when the user completes the reorder gesture by removing their pointer from the screen. The event includes the `from` and `to` indices of the item, as well as the `complete` method that should be called to finalize the reorder operation. The `from` index will always be the position of the item when the gesture started, while the `to` index will be its final position. This event will fire even if no items have changed position, in which case the `from` and `to` indices will be the same.
83+
8084
import ReorderStartEnd from '@site/static/usage/v8/reorder/reorder-start-end/index.md';
8185

8286
<ReorderStartEnd />
8387

8488
### Using `ionReorderMove`
8589

90+
The `ionReorderMove` event is emitted continuously during the reorder gesture as the user drags an item. The event includes the `from` and `to` indices of the item. Unlike `ionReorderEnd`, the `from` index in this event represents the last known position of the item (which updates as the item moves), while the `to` index represents its current position. If the item has not changed position since the last event, the `from` and `to` indices will be the same. This event is useful for tracking position changes during the drag operation. For example, the ranking or numbering of items can be updated in real-time as they are being dragged to maintain a logical ascending order.
91+
92+
:::warning
93+
Do not call the `complete` method during the `ionReorderMove` event as it can break the gesture.
94+
:::
95+
8696
import ReorderMove from '@site/static/usage/v8/reorder/reorder-move/index.md';
8797

8898
<ReorderMove />

static/usage/v8/reorder/reorder-move/angular/example_component_ts.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ export class ExampleComponent {
2323
const from = event.detail.from;
2424
const to = event.detail.to;
2525

26+
if (from !== to) {
27+
console.log('Dragged from index', from, 'to', to);
28+
}
29+
2630
// Get all items and sort by their current id (item-1, item-2, ...)
2731
const itemElements = Array.from(document.querySelectorAll('ion-item')).sort((a, b) => {
2832
const aNum = parseInt(a.id.replace('item-', ''), 10);

static/usage/v8/reorder/reorder-move/demo.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
const from = detail.from;
4747
const to = detail.to;
4848

49+
if (from !== to) {
50+
console.log('Dragged from index', from, 'to', to);
51+
}
52+
4953
// Get all items and sort by their current id (item-1, item-2, ...)
5054
const itemElements = Array.from(reorderGroup.querySelectorAll('ion-item')).sort((a, b) => {
5155
const aNum = parseInt(a.id.replace('item-', ''), 10);

static/usage/v8/reorder/reorder-move/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ import angular_example_component_html from './angular/example_component_html.md'
2222
}}
2323
src="usage/v8/reorder/reorder-move/demo.html"
2424
size="300px"
25+
showConsole={true}
2526
/>

static/usage/v8/reorder/reorder-move/javascript.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
const from = detail.from;
1515
const to = detail.to;
1616
17+
if (from !== to) {
18+
console.log('Dragged from index', from, 'to', to);
19+
}
20+
1721
// Get all items and sort by their current id (item-1, item-2, ...)
1822
const itemElements = Array.from(reorderGroup.querySelectorAll('ion-item')).sort((a, b) => {
1923
const aNum = parseInt(a.id.replace('item-', ''), 10);

static/usage/v8/reorder/reorder-move/react.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ function Example() {
2323
const from = event.detail.from;
2424
const to = event.detail.to;
2525

26+
if (from !== to) {
27+
console.log('Dragged from index', from, 'to', to);
28+
}
29+
2630
// Get all items and sort by their current id (item-1, item-2, ...)
2731
const itemElements = Array.from(document.querySelectorAll('ion-item')).sort((a, b) => {
2832
const aNum = parseInt(a.id.replace('item-', ''), 10);

static/usage/v8/reorder/reorder-move/vue.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
const from = event.detail.from;
2323
const to = event.detail.to;
2424
25+
if (from !== to) {
26+
console.log('Dragged from index', from, 'to', to);
27+
}
28+
2529
// Get all items and sort by their current id (item-1, item-2, ...)
2630
const itemElements = Array.from(document.querySelectorAll('ion-item')).sort((a, b) => {
2731
const aNum = parseInt(a.id.replace('item-', ''), 10);

static/usage/v8/reorder/reorder-start-end/angular/example_component_ts.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,17 @@ export class ExampleComponent {
3939
}
4040

4141
handleReorderStart() {
42+
console.log('Reorder started');
43+
4244
// Hide the icons when the reorder starts
4345
this.icons.forEach((icon) => {
4446
icon.nativeElement.style.opacity = '0';
4547
});
4648
}
4749

4850
handleReorderEnd(event: ReorderEndCustomEvent) {
51+
console.log('Dragged from index', event.detail.from, 'to', event.detail.to);
52+
4953
// Show the icons again
5054
this.icons.forEach((icon) => {
5155
icon.nativeElement.style.opacity = '1';

static/usage/v8/reorder/reorder-start-end/demo.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,18 @@
6363
<script>
6464
const reorderGroup = document.querySelector('ion-reorder-group');
6565
const icons = document.querySelectorAll('ion-icon');
66-
reorderGroup.addEventListener('ionReorderStart', ({ detail }) => {
66+
reorderGroup.addEventListener('ionReorderStart', () => {
67+
console.log('Reorder started');
68+
6769
// Hide the icons when the reorder starts
6870
icons.forEach((icon) => {
6971
icon.style.opacity = 0;
7072
});
7173
});
7274

7375
reorderGroup.addEventListener('ionReorderEnd', ({ detail }) => {
76+
console.log('Dragged from index', detail.from, 'to', detail.to);
77+
7478
// Show the icons again
7579
icons.forEach((icon) => {
7680
icon.style.opacity = 1;

static/usage/v8/reorder/reorder-start-end/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ import angular_example_component_ts from './angular/example_component_ts.md';
2929
}}
3030
src="usage/v8/reorder/reorder-start-end/demo.html"
3131
size="300px"
32+
showConsole={true}
3233
/>

0 commit comments

Comments
 (0)