-
Notifications
You must be signed in to change notification settings - Fork 3.2k
docs(reorder): add new ionReorderStart, ionReorderMove, ionReorderEnd event playgrounds #4149
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
Open
brandyscarney
wants to merge
18
commits into
feature-8.7
Choose a base branch
from
FW-6539
base: feature-8.7
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
7b0dbe3
chore: use dev build
brandyscarney bd0ffe1
docs(reorder): update onIonItemReorder -> onIonReorderEnd
brandyscarney 90f462b
style: lint
brandyscarney 3aa1aed
fix(api): update the events table to include the deprecated description
brandyscarney 5d0650e
docs(reorder-group): add new interfaces and deprecate old ones
brandyscarney 1e17d00
chore: latest dev build
brandyscarney 74242aa
fix(api): bold deprecated and move to its own line
brandyscarney 7ee85c5
docs(reorder): ionItemReorder -> ionReorderEnd
brandyscarney f114d9e
docs(reorder): set width of existing demos to 300px
brandyscarney 9adb9df
docs(reorder): CustomEvent<ItemReorderEventDetail> -> ReorderEndCusto…
brandyscarney ed7849d
docs(reorder): rename handleReorder functions to handleReorderEnd
brandyscarney 5ca302b
style: lint
brandyscarney b8b0dff
docs(reorder): add reorder-start-end playground
brandyscarney cfb9b81
style: comments and logs
brandyscarney c5a4ad3
docs(reorder): update reorder start end to set items data
brandyscarney 22526c3
docs(reorder): add reorder move playground
brandyscarney 11aefdb
docs(reorder): update event handling descriptions and add logs
brandyscarney e2012ad
docs(reorder): rename playgrounds
brandyscarney 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
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 |
---|---|---|
|
@@ -20,7 +20,7 @@ import EncapsulationPill from '@components/page/api/EncapsulationPill'; | |
|
||
Reorder is a component that allows an item to be dragged to change its order within a group of items. It must be used within a [reorder group](./reorder-group) to provide a visual drag and drop interface. | ||
|
||
The reorder is the anchor used to drag and drop the items. Once the reorder is complete, the `ionItemReorder` event will be dispatched from the reorder group and the `complete` method needs to be called. | ||
The reorder is the anchor used to drag and drop the items. Once the reorder is complete, the `ionReorderEnd` event will be dispatched from the reorder group and the `complete` method needs to be called. | ||
|
||
|
||
## Basic Usage | ||
|
@@ -73,6 +73,29 @@ import UpdatingData from '@site/static/usage/v8/reorder/updating-data/index.md'; | |
|
||
<UpdatingData /> | ||
|
||
## Event Handling | ||
|
||
### Using `ionReorderStart` and `ionReorderEnd` | ||
|
||
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. | ||
|
||
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. | ||
|
||
import ReorderStartEndEvents from '@site/static/usage/v8/reorder/reorder-start-end-events/index.md'; | ||
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. I didn't like how range prefixes |
||
|
||
<ReorderStartEndEvents /> | ||
|
||
### Using `ionReorderMove` | ||
|
||
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. | ||
|
||
:::warning | ||
Do not call the `complete` method during the `ionReorderMove` event as it can break the gesture. | ||
::: | ||
|
||
import ReorderMoveEvent from '@site/static/usage/v8/reorder/reorder-move-event/index.md'; | ||
|
||
<ReorderMoveEvent /> | ||
|
||
## Usage with Virtual Scroll | ||
|
||
|
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
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
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
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"dependencies": { | ||
"@ionic/core": "8.6.0", | ||
"@ionic/core": "8.6.2-dev.11749759855.198287b7", | ||
"ionicons": "8.0.9" | ||
} | ||
} |
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
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
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
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
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
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 |
---|---|---|
|
@@ -6,12 +6,18 @@ | |
<title>Reorder</title> | ||
<link rel="stylesheet" href="../../common.css" /> | ||
<script src="../../common.js"></script> | ||
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@8/dist/ionic/ionic.esm.js"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@8/css/ionic.bundle.css" /> | ||
<script | ||
type="module" | ||
src="https://cdn.jsdelivr.net/npm/@ionic/[email protected]/dist/ionic/ionic.esm.js" | ||
></script> | ||
<link | ||
rel="stylesheet" | ||
href="https://cdn.jsdelivr.net/npm/@ionic/[email protected]/css/ionic.bundle.css" | ||
/> | ||
|
||
<style> | ||
ion-list { | ||
width: 100%; | ||
width: 300px; | ||
} | ||
</style> | ||
</head> | ||
|
@@ -56,14 +62,14 @@ | |
<script> | ||
const reorderGroup = document.querySelector('ion-reorder-group'); | ||
|
||
reorderGroup.addEventListener('ionItemReorder', ({ detail }) => { | ||
reorderGroup.addEventListener('ionReorderEnd', ({ detail }) => { | ||
// The `from` and `to` properties contain the index of the item | ||
// when the drag started and ended, respectively | ||
console.log('Dragged from index', detail.from, 'to', detail.to); | ||
|
||
// Finish the reorder and position the item in the DOM based on | ||
// where the gesture ended. This method can also be called directly | ||
// by the reorder group | ||
// by the reorder group. | ||
detail.complete(); | ||
}); | ||
</script> | ||
|
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
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
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
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
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.
I don't love these section headings, but I decided to be consistent with how Range documents its events. If we want to change this I can update both components.