Fix album drag-drop when you drag by the thumbnail or other child.

This commit is contained in:
voussoir 2020-09-03 15:39:34 -07:00
parent dae5815239
commit 9a9edecfd2

View file

@ -395,9 +395,25 @@ function create_child(title)
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)
{
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)
{