Fix album drag-drop when you drag by the thumbnail or other child.
This commit is contained in:
parent
dae5815239
commit
9a9edecfd2
1 changed files with 17 additions and 1 deletions
|
@ -395,9 +395,25 @@ function create_child(title)
|
||||||
api.albums.create(title, parent_id, api.albums.callback_follow);
|
api.albums.create(title, parent_id, api.albums.callback_follow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_album_card_from_child(element)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Given an element which is known to be a child of an album card, navigate up
|
||||||
|
the parent tree until we find that album card.
|
||||||
|
This is used to make drag-and-drop work even when you start your drag by
|
||||||
|
clicking on the album's thumbnail, title, etc.
|
||||||
|
*/
|
||||||
|
while (! element.classList.contains("album_card"))
|
||||||
|
{
|
||||||
|
element = element.parentElement;
|
||||||
|
}
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
function on_album_drag_start(event)
|
function on_album_drag_start(event)
|
||||||
{
|
{
|
||||||
event.dataTransfer.setData("text/plain", event.target.id);
|
let album_card = get_album_card_from_child(event.target);
|
||||||
|
event.dataTransfer.setData("text/plain", album_card.id);
|
||||||
}
|
}
|
||||||
function on_album_drag_end(event)
|
function on_album_drag_end(event)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue