Skip to content

Commit

Permalink
refactor(reorder): using class instead of Object.assign()
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Nov 20, 2016
1 parent 5cb7e0c commit ba18030
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/components/item/item-reorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import { ItemReorderGesture } from '../item/item-reorder-gesture';
import { isTrueProperty, reorderArray } from '../../util/util';


export interface ReorderIndexes {
from: number;
to: number;
applyTo: Function;
export class ReorderIndexes {
constructor(public from: number, public to: number) {}

applyTo(array: any) {
reorderArray(array, this);
}
}

/**
Expand Down Expand Up @@ -216,10 +218,8 @@ export class ItemReorder {
this._reorderReset();
if (fromIndex !== toIndex) {
this._zone.run(() => {
const indexes = { from: fromIndex, to: toIndex };
this.ionItemReorder.emit(Object.assign({
applyTo: (array) => reorderArray(array, indexes)
}, indexes));
const indexes = new ReorderIndexes(fromIndex, toIndex);
this.ionItemReorder.emit(indexes);
});
}
}
Expand Down

0 comments on commit ba18030

Please sign in to comment.