Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
onDrop(src: Todo, trg: Todo) {
this._moveRow(src.order, trg.order);
}
_moveRow(src, trg) {
src = parseInt(src);
trg = parseInt(trg);
// If the element was moved down
if (src > trg) {
for (let i = trg; i < src; i++) {
this.todos[i].order++;
}
} else { // if the element was moved up
for (let i = src + 1; i <= trg; i++) {
this.todos[i].order--;
}
}
this.todos[src].order = trg;
this.todos.sort((a, b) => a.order - b.order);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.