Rebounce navigation events
This commit is contained in:
@@ -69,7 +69,7 @@ const file_event: FileActionHandler = (action: FileAction, index: number, orig:
|
||||
if (navigator.maxTouchPoints && navigator.maxTouchPoints > 0) {
|
||||
select_node(index)
|
||||
} else {
|
||||
file_menu.open(nav.children[index], orig.target)
|
||||
file_menu.open(nav.children[index], orig.target, orig)
|
||||
}
|
||||
break
|
||||
case FileAction.Edit:
|
||||
@@ -86,7 +86,7 @@ const file_event: FileActionHandler = (action: FileAction, index: number, orig:
|
||||
select_node(index)
|
||||
break
|
||||
case FileAction.Menu:
|
||||
file_menu.open(nav.children[index], orig.target)
|
||||
file_menu.open(nav.children[index], orig.target, orig)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,16 +19,23 @@ let {
|
||||
let dialog: Dialog = $state()
|
||||
let node: FSNode = $state(null)
|
||||
|
||||
export const open = async (n: FSNode, target: EventTarget) => {
|
||||
export const open = async (n: FSNode, target: EventTarget, event: Event) => {
|
||||
node = n
|
||||
let el: HTMLElement = (target as Element).closest("button")
|
||||
if (el === null) {
|
||||
el = (target as Element).closest("a")
|
||||
}
|
||||
|
||||
// Wait for the view to update, so the dialog gets the proper measurements
|
||||
await tick()
|
||||
dialog.open(el.getBoundingClientRect())
|
||||
|
||||
let el: HTMLElement = (target as Element).closest("button")
|
||||
if (el !== null) {
|
||||
dialog.open(el.getBoundingClientRect())
|
||||
return
|
||||
}
|
||||
|
||||
if (event instanceof MouseEvent) {
|
||||
dialog.open(event)
|
||||
return
|
||||
}
|
||||
|
||||
console.error("Cannot find suitable target for spawning dialog window")
|
||||
}
|
||||
|
||||
const delete_node = async () => {
|
||||
|
||||
Reference in New Issue
Block a user