mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-02 13:02:00 +08:00
fix(mobile): display of context menu on iOS
This commit is contained in:
parent
12eff0fef5
commit
bd10babd1b
@ -53,6 +53,7 @@ class ContextMenu {
|
||||
}
|
||||
|
||||
async show<T extends CommandNames>(options: ContextMenuOptions<T>) {
|
||||
console.warn(new Error().stack);
|
||||
this.options = options;
|
||||
|
||||
if (this.$widget.hasClass("show")) {
|
||||
|
@ -601,7 +601,32 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||
}
|
||||
});
|
||||
|
||||
if (!utils.isMobile()) {
|
||||
const isMobile = utils.isMobile();
|
||||
|
||||
if (isMobile) {
|
||||
let showTimeout;
|
||||
|
||||
this.$tree.on("touchstart", ".fancytree-node", (e) => {
|
||||
touchStart = new Date().getTime();
|
||||
showTimeout = setTimeout(() => {
|
||||
this.showContextMenu(e);
|
||||
}, 300)
|
||||
});
|
||||
|
||||
this.$tree.on("touchmove", ".fancytree-node", (e) => {
|
||||
clearTimeout(showTimeout);
|
||||
});
|
||||
|
||||
this.$tree.on("touchend", ".fancytree-node", (e) => {
|
||||
clearTimeout(showTimeout);
|
||||
e.preventDefault();
|
||||
});
|
||||
} else {
|
||||
this.$tree.on('contextmenu', '.fancytree-node', e => {
|
||||
this.showContextMenu(e);
|
||||
return false; // blocks default browser right click menu
|
||||
});
|
||||
|
||||
this.getHotKeys().then(hotKeys => {
|
||||
for (const key in hotKeys) {
|
||||
const handler = hotKeys[key];
|
||||
@ -615,7 +640,12 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||
});
|
||||
}
|
||||
|
||||
this.$tree.on('contextmenu', '.fancytree-node', e => {
|
||||
let touchStart;
|
||||
|
||||
this.tree = $.ui.fancytree.getTree(this.$tree);
|
||||
}
|
||||
|
||||
showContextMenu(e) {
|
||||
const node = $.ui.fancytree.getNode(e);
|
||||
const note = froca.getNoteFromCache(node.data.noteId);
|
||||
|
||||
@ -630,11 +660,6 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||
treeContextMenu.show(e);
|
||||
});
|
||||
}
|
||||
|
||||
return false; // blocks default browser right click menu
|
||||
});
|
||||
|
||||
this.tree = $.ui.fancytree.getTree(this.$tree);
|
||||
}
|
||||
|
||||
prepareRootNode() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user