Skip to content

Instantly share code, notes, and snippets.

@alejandrosobko
Created November 19, 2018 15:47
Show Gist options
  • Save alejandrosobko/f5357ccbb96537735b3bbf5ac6d3a0af to your computer and use it in GitHub Desktop.
Save alejandrosobko/f5357ccbb96537735b3bbf5ac6d3a0af to your computer and use it in GitHub Desktop.
public onDragEnd(result: any) {
const { destination, source, draggableId } = result;
if (!destination) { return }
const column = this.state.column;
const numberIds = Array.from(column.numberIds);
numberIds.splice(source.index, 1);
numberIds.splice(destination.index, 0, draggableId);
const numbers = numberIds.map((numberId: string) =>
parseInt(this.state.numbers[numberId].content, 10));
this.playSound(numbers);
this.updateState(column, numberIds);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment