Swipable menu, draggable bookmarks

This commit is contained in:
2026-02-19 18:15:06 +01:00
parent 38566389db
commit d756d545db
10 changed files with 277 additions and 98 deletions

View File

@@ -56,7 +56,7 @@ export class FSNavigator {
last_requested_path: string = ""
navigate = async (path: string, push_history: boolean) => {
if (path === this.last_requested_path) {
console.debug("FSNavigator: Requested path is equal to current path. Debouncing")
console.debug("FSNavigator: Requested path ", path, " is equal to current path. Debouncing")
return
}
this.last_requested_path = path
@@ -96,6 +96,7 @@ export class FSNavigator {
}
reload = async () => {
this.last_requested_path = ""
await this.navigate(this.base.path, false)
}
@@ -282,3 +283,23 @@ const sort_children = (children: FSNode[], field: string, asc: boolean) => {
}
export let global_navigator = new FSNavigator(true)
export const path_link = (node: HTMLAnchorElement, data: { nav: FSNavigator, node: FSNode }) => {
// Set url
node.href = "/d" + fs_encode_path(data.node.path)
// Override click handler
const click = (e: MouseEvent) => {
e.preventDefault()
data.nav.navigate(data.node.path, true)
}
node.addEventListener("click", click)
return {
destroy() {
node.removeEventListener("click", click)
}
}
}