From a858a6ace3b1608ef31f99ff31087c6dcadd6f74 Mon Sep 17 00:00:00 2001 From: Sight <1453017105@qq.com> Date: Sat, 28 May 2022 13:17:48 +0000 Subject: [PATCH] =?UTF-8?q?fix(menu):=20=E8=A7=A3=E5=86=B3=E8=87=AA?= =?UTF-8?q?=E9=80=82=E5=BA=94=E5=AE=BD=E5=BA=A6=E6=96=B9=E6=B3=95=E5=92=8C?= =?UTF-8?q?=E6=A1=86=E6=9E=B6=E8=80=A6=E5=90=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/pear/module/menu.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/component/pear/module/menu.js b/component/pear/module/menu.js index 0f2a119..b9704e1 100644 --- a/component/pear/module/menu.js +++ b/component/pear/module/menu.js @@ -542,14 +542,19 @@ layui.define(['table', 'jquery', 'element'], function (exports) { } function rationalizeHeaderControlWidth(option) { - var $headerControl = $(".layui-layout-control"); - var $headerRight = $(".layui-layout-right"); - var rationalizeWidth = $headerRight.position().left - $headerControl.position().left; + var $headerControl = $("#" + option.control); + var $nextEl = $headerControl.next(); + var rationalizeWidth; + if ($nextEl.length) { + rationalizeWidth = $nextEl.position().left - $headerControl.position().left; + } else { + rationalizeWidth = $headerControl.parent().innerWidth() - $headerControl.position().left; + } + if (option.controlWidth && rationalizeWidth >= option.controlWidth) { rationalizeWidth = option.controlWidth; } - $(".layui-layout-control .control").css({ "width": rationalizeWidth, "transition": "width .15s"}); - + $("#" + option.control + " .control").css({ "width": rationalizeWidth, "transition": "width .15s" }); } function rationalizeHeaderControlWidthAuto(option){ -- Gitee