Drag-and-drop within tracklists
This commit is contained in:
@ -40,32 +40,45 @@ export function lazyLoading( start ){
|
||||
}
|
||||
}
|
||||
|
||||
export function dragStart( e, context, victims ){
|
||||
export function dragStart( e, context, victims, victims_indexes = false ){
|
||||
return {
|
||||
type: 'DRAG_START',
|
||||
context: context,
|
||||
victims: victims,
|
||||
position_x: e.clientX,
|
||||
position_y: e.clientY
|
||||
victims_indexes: victims_indexes,
|
||||
start_x: e.clientX,
|
||||
start_y: e.clientY
|
||||
}
|
||||
}
|
||||
|
||||
export function dragMove( e ){
|
||||
return {
|
||||
type: 'DRAG_MOVE',
|
||||
position_x: e.clientX,
|
||||
position_y: e.clientY,
|
||||
}
|
||||
}
|
||||
|
||||
export function dragCancel(){
|
||||
return { type: 'DRAG_CANCEL' }
|
||||
export function dragActive(){
|
||||
return { type: 'DRAG_ACTIVE' }
|
||||
}
|
||||
|
||||
export function dragEnd(){
|
||||
return { type: 'DRAG_END' }
|
||||
}
|
||||
|
||||
export function reorderTracks( context, indexes, destination_index ){
|
||||
console.log('uiActions.reorderTracks', context, indexes, destination_index)
|
||||
switch( context ){
|
||||
|
||||
case 'queue':
|
||||
return {
|
||||
type: 'MOPIDY_REORDER_TRACKLIST',
|
||||
indexes: indexes,
|
||||
destination_index: destination_index
|
||||
}
|
||||
|
||||
case 'editable-playlist':
|
||||
return {
|
||||
type: 'SPOTIFY_REORDER_TRACKLIST',
|
||||
indexes: indexes,
|
||||
destination_index: destination_index
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function savePlaylist( uri, name, is_public = false ){
|
||||
switch( helpers.uriSource( uri ) ){
|
||||
|
||||
|
||||
@ -34,36 +34,22 @@ export default function reducer(ui = {}, action){
|
||||
return Object.assign({}, ui, {
|
||||
dragger: {
|
||||
dragging: true,
|
||||
active: false,
|
||||
context: action.context,
|
||||
victims: action.victims,
|
||||
position_x: action.position_x,
|
||||
position_y: action.position_y
|
||||
victims_indexes: action.victims_indexes,
|
||||
start_x: action.start_x,
|
||||
start_y: action.start_y
|
||||
}
|
||||
});
|
||||
|
||||
case 'DRAG_MOVE':
|
||||
var dragger = Object.assign({}, ui.dragger, {
|
||||
position_x: action.position_x,
|
||||
position_y: action.position_y
|
||||
})
|
||||
case 'DRAG_ACTIVE':
|
||||
var dragger = Object.assign({}, ui.dragger, { active: true })
|
||||
return Object.assign({}, ui, { dragger: dragger });
|
||||
|
||||
case 'DRAG_END':
|
||||
return Object.assign({}, ui, {
|
||||
dragger: {
|
||||
dragging: false,
|
||||
context: false,
|
||||
victims: false
|
||||
}
|
||||
});
|
||||
|
||||
case 'DRAG_CANCEL':
|
||||
return Object.assign({}, ui, {
|
||||
dragger: {
|
||||
dragging: false,
|
||||
context: false,
|
||||
victims: false
|
||||
}
|
||||
dragger: false
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user