Skip to content

Instantly share code, notes, and snippets.

@codehz
Created July 12, 2016 16:21
Show Gist options
  • Save codehz/266db4303fe087bfdc8b63908ce830e8 to your computer and use it in GitHub Desktop.
Save codehz/266db4303fe087bfdc8b63908ce830e8 to your computer and use it in GitHub Desktop.
Action delete, moveUp and moveDown
playListAction({action, index}) {
switch (action) {
case 'delete':
this.playList.splice(index, 1);
break;
case 'moveUp':
this.playList.splice((index - 1 + this.playList.length) % this.playList.length, 0, this.playList.splice(index, 0));
break;
case 'moveDown':
this.playList.splice((index + 1) % this.playList.length, 0, this.playList.splice(index, 0));
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment