mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-12-02 10:02:12 +00:00
fix sortable
This commit is contained in:
@@ -28,16 +28,7 @@
|
||||
setContext('recursive', recursive);
|
||||
|
||||
onMount(() => {
|
||||
if (orientation === 'vertical') {
|
||||
selection.update(($selection) => {
|
||||
$selection.forEach((item) => {
|
||||
if ($selection.hasAnyChildren(item, false)) {
|
||||
$selection.toggle(item);
|
||||
}
|
||||
});
|
||||
return $selection;
|
||||
});
|
||||
} else {
|
||||
if (orientation === 'horizontal') {
|
||||
selection.update(($selection) => {
|
||||
$selection.forEach((item) => {
|
||||
if (!(item instanceof ListFileItem)) {
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (sortable) {
|
||||
if (sortable && node) {
|
||||
sortable.updateElements();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@ import { get, writable, type Readable } from 'svelte/store';
|
||||
import { settings } from '$lib/logic/settings';
|
||||
import type { GPXFileWithStatistics } from '$lib/logic/statistics-tree';
|
||||
import type { AnyGPXTreeElement, GPXTreeElement, Waypoint } from 'gpx';
|
||||
import { tick } from 'svelte';
|
||||
|
||||
const { fileOrder } = settings;
|
||||
|
||||
@@ -89,7 +90,9 @@ export class SortableFileList {
|
||||
writable: true,
|
||||
});
|
||||
|
||||
this._unsubscribes.push(selection.subscribe(() => this.updateFromSelection()));
|
||||
this._unsubscribes.push(
|
||||
selection.subscribe(() => tick().then(() => this.updateFromSelection()))
|
||||
);
|
||||
this._unsubscribes.push(fileOrder.subscribe(() => this.updateFromFileOrder()));
|
||||
}
|
||||
|
||||
@@ -172,9 +175,8 @@ export class SortableFileList {
|
||||
}
|
||||
|
||||
updateToSelection(e: Sortable.SortableEvent) {
|
||||
if (this._updatingSelection) {
|
||||
return;
|
||||
}
|
||||
if (!this._sortable) return;
|
||||
if (this._updatingSelection) return;
|
||||
this._updatingSelection = true;
|
||||
const changed = this.getChangedIds();
|
||||
if (changed.length == 0) {
|
||||
@@ -200,7 +202,6 @@ export class SortableFileList {
|
||||
$selection.clear();
|
||||
$selection.set(this._item.extend(this.getRealId(changed[0])), true);
|
||||
}
|
||||
|
||||
return $selection;
|
||||
});
|
||||
this._updatingSelection = false;
|
||||
@@ -255,6 +256,7 @@ export class SortableFileList {
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this._sortable = null;
|
||||
this._unsubscribes.forEach((unsubscribe) => unsubscribe());
|
||||
this._unsubscribes = [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user