improving drag'n'drop of locations

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-10-25 23:26:40 +02:00
parent 3caf51f52d
commit ea616ed2a1

View File

@@ -24,6 +24,11 @@
return false; return false;
} }
function start_drag(e,loc){
e.stopPropagation();
drag_start(loc)
}
function flat(x){ function flat(x){
return JSON.parse(JSON.stringify(x)); return JSON.parse(JSON.stringify(x));
} }
@@ -98,12 +103,6 @@
} }
</script> </script>
<style>
.highlight > span{
background: lime;
}
</style>
<ul> <ul>
{#each locations as location} {#each locations as location}
<li onclick={e => toggleChildren(e, location)} <li onclick={e => toggleChildren(e, location)}
@@ -112,7 +111,7 @@
ondragover={e => drag_over(e,location)} ondragover={e => drag_over(e,location)}
ondrop={e => onDrop(e,location)} ondrop={e => onDrop(e,location)}
ondragleave={e => delete location.highlight} ondragleave={e => delete location.highlight}
ondragstart={e => drag_start(location)} > ondragstart={e => start_drag(e,location)} >
<span class="name">{location.name}</span> <span class="name">{location.name}</span>
{#if location.locations} {#if location.locations}
<svelte:self locations={location.locations} {drag_start} {move_dragged_to} parent={{location:location.id}} bind:selected /> <svelte:self locations={location.locations} {drag_start} {move_dragged_to} parent={{location:location.id}} bind:selected />