From 9ea3da3a1ea5e41c4024319c4989b129cfbda3c8 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sun, 2 Apr 2023 11:26:04 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/7852 --- app/src/assets/scss/component/_menu.scss | 2 +- app/src/menus/Menu.ts | 9 +++++++-- app/src/mobile/util/MobileFiles.ts | 24 +++++++++++++++++++----- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/app/src/assets/scss/component/_menu.scss b/app/src/assets/scss/component/_menu.scss index 32d1df8c1..a817e6692 100644 --- a/app/src/assets/scss/component/_menu.scss +++ b/app/src/assets/scss/component/_menu.scss @@ -42,7 +42,7 @@ .b3-menu { &__submenu { - top: 49px; + top: 48.5px; left: 0; bottom: 0; max-height: none; diff --git a/app/src/menus/Menu.ts b/app/src/menus/Menu.ts index 47c1d13bc..0f8e197a6 100644 --- a/app/src/menus/Menu.ts +++ b/app/src/menus/Menu.ts @@ -120,13 +120,18 @@ export class Menu { setPosition(this.element, options.x - (isLeft ? window.siyuan.menus.menu.element.clientWidth : 0), options.y, options.h, options.w); } - public fullscreen() { + public fullscreen(position: "bottom" | "all" = "all") { this.element.classList.add("b3-menu--fullscreen"); this.element.insertAdjacentHTML("afterbegin", `
${window.siyuan.languages.back}
`); - this.popup({x: 0, y: 0}); + if (position === "bottom" ) { + this.element.querySelectorAll(".b3-menu__submenu").forEach((item:HTMLElement) => { + item.style.top = "calc(50vh + 48.5px)"; + }) + } + this.popup({x: 0, y: position === "bottom" ? window.innerHeight / 2 : 0}); } } diff --git a/app/src/mobile/util/MobileFiles.ts b/app/src/mobile/util/MobileFiles.ts index 5f11abecd..578e77ae5 100644 --- a/app/src/mobile/util/MobileFiles.ts +++ b/app/src/mobile/util/MobileFiles.ts @@ -12,6 +12,7 @@ import {unicode2Emoji} from "../../emoji"; import {mountHelp, newNotebook} from "../../util/mount"; import {confirmDialog} from "../../dialog/confirmDialog"; import {newFile} from "../../util/newFile"; +import {isMobile} from "../../util/functions"; export class MobileFiles extends Model { public element: HTMLElement; @@ -175,15 +176,28 @@ export class MobileFiles extends Model { if (type === "new") { newFile(notebookId, pathString); } else if (type === "more-root") { - initNavigationMenu(target.parentElement).popup({x, y}); + initNavigationMenu(target.parentElement) + if (isMobile()) { + window.siyuan.menus.menu.fullscreen("bottom"); + } else { + window.siyuan.menus.menu.popup({ + x, + y + }); + } window.siyuan.menus.menu.element.style.zIndex = "310"; } } if (type === "more-file") { - initFileMenu(notebookId, pathString, target.parentElement).popup({ - x, - y - }); + initFileMenu(notebookId, pathString, target.parentElement); + if (isMobile()) { + window.siyuan.menus.menu.fullscreen("bottom"); + } else { + window.siyuan.menus.menu.popup({ + x, + y + }); + } window.siyuan.menus.menu.element.style.zIndex = "310"; } }