@@ -4,12 +4,13 @@ import { Content } from '../content/content';
4
4
import { CSS , zoneRafFrames } from '../../util/dom' ;
5
5
import { Item } from './item' ;
6
6
import { ItemReorderGesture } from '../item/item-reorder-gesture' ;
7
- import { isTrueProperty } from '../../util/util' ;
7
+ import { isTrueProperty , reorderArray } from '../../util/util' ;
8
8
9
9
10
10
export interface ReorderIndexes {
11
11
from : number ;
12
12
to : number ;
13
+ applyTo : Function ;
13
14
}
14
15
15
16
/**
@@ -118,6 +119,16 @@ export interface ReorderIndexes {
118
119
* }
119
120
* }
120
121
* ```
122
+ * Alternatevely you can execute helper function inside template:
123
+ *
124
+ * ```html
125
+ * <ion-list>
126
+ * <ion-list-header>Header</ion-list-header>
127
+ * <ion-item-group reorder="true" (ionItemReorder)="$event.applyTo(items)">
128
+ * <ion-item *ngFor="let item of items">{% raw %}{{ item }}{% endraw %}</ion-item>
129
+ * </ion-item-group>
130
+ * </ion-list>
131
+ * ```
121
132
*
122
133
* @demo /docs/v2/demos/src/item-reorder/
123
134
* @see {@link /docs/v2/components#lists List Component Docs }
@@ -223,10 +234,10 @@ export class ItemReorder {
223
234
this . reorderReset ( ) ;
224
235
if ( fromIndex !== toIndex ) {
225
236
this . _zone . run ( ( ) => {
226
- this . ionItemReorder . emit ( {
227
- from : fromIndex ,
228
- to : toIndex ,
229
- } ) ;
237
+ const indexes = { from : fromIndex , to : toIndex } ;
238
+ this . ionItemReorder . emit ( Object . assign ( {
239
+ applyTo : ( array ) => reorderArray ( array , indexes )
240
+ } , indexes ) ) ;
230
241
} ) ;
231
242
}
232
243
}
@@ -368,4 +379,3 @@ export function indexForItem(element: any): number {
368
379
export function reorderListForItem ( element : any ) : any {
369
380
return element [ '$ionReorderList' ] ;
370
381
}
371
-
0 commit comments