From eb00fed0ad73219960c9615fc936544f53b89320 Mon Sep 17 00:00:00 2001 From: kuangthree Date: Wed, 21 Feb 2024 23:00:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86menu=E4=B8=AD=E7=9A=84game.documentZoo?= =?UTF-8?q?m=E6=94=B9=E6=88=90get.menuZoom()=E4=BE=BF=E4=BA=8E=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/get/index.js | 6 ++++++ noname/ui/create/menu/index.js | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/noname/get/index.js b/noname/get/index.js index 82b671517..0ff7cc609 100644 --- a/noname/get/index.js +++ b/noname/get/index.js @@ -2226,6 +2226,12 @@ export class Get extends Uninstantable { } return ''; } + static menuZoom(){ + if(game.menuZoom === undefined || game.menuZoom === null){ + return game.documentZoom; + } + return game.menuZoom; + } static strNumber(num) { switch (num) { case 1: return 'A'; diff --git a/noname/ui/create/menu/index.js b/noname/ui/create/menu/index.js index 9180b7832..4b9b2a79d 100644 --- a/noname/ui/create/menu/index.js +++ b/noname/ui/create/menu/index.js @@ -2,7 +2,7 @@ import { ui, game, get, lib, _status } from "../../../../noname.js"; export function openMenu(node, e, onclose) { popupContainer.innerHTML = ''; - var left = Math.round(e.clientX / game.documentZoom); + var left = Math.round(e.clientX / get.menuZoom()); var zoom = get.is.phoneLayout() ? 1.3 : 1; popupContainer.appendChild(node); // var rect=node.getBoundingClientRect(); @@ -23,7 +23,7 @@ export function openMenu(node, e, onclose) { // } // if(e){ var height = node.offsetHeight; - var idealtop = e.clientY / game.documentZoom; + var idealtop = e.clientY / get.menuZoom(); if (idealtop < 10) { idealtop = 10; } @@ -141,7 +141,7 @@ export function createMenu(connectMenu, tabs, config) { var menuTab = ui.create.div('.menu-tab', menu); var menuTabBar = ui.create.div('.menu-tab-bar', menu); menuTabBar.style.left = (config.bar || 0) + 'px'; - if (Math.round(2 * game.documentZoom) < 2) { + if (Math.round(2 * get.menuZoom()) < 2) { menuTabBar.style.height = '3px'; } var menuContent = ui.create.div('.menu-content', menu); @@ -153,7 +153,7 @@ export function createMenu(connectMenu, tabs, config) { active._link.remove(); } this.classList.add('active'); - menuTabBar.style.transform = 'translateX(' + (this.getBoundingClientRect().left - this.parentNode.firstChild.getBoundingClientRect().left) / game.documentZoom + 'px)'; + menuTabBar.style.transform = 'translateX(' + (this.getBoundingClientRect().left - this.parentNode.firstChild.getBoundingClientRect().left) / get.menuZoom() + 'px)'; menuContent.appendChild(this._link); }; ui.click.menuTab = function (tab) {