From ebaa2fdf0965929c93b4c4bf19117ec70683bd96 Mon Sep 17 00:00:00 2001 From: dailer Date: Tue, 20 Jun 2023 09:44:03 +0800 Subject: [PATCH] update --- .../fineui/src/core/platform/web/config.js | 47 +++++++++++-------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/packages/fineui/src/core/platform/web/config.js b/packages/fineui/src/core/platform/web/config.js index c1f3658c8..554af7a74 100644 --- a/packages/fineui/src/core/platform/web/config.js +++ b/packages/fineui/src/core/platform/web/config.js @@ -3,7 +3,8 @@ import { Providers } from "../../5.inject"; import { Plugin } from "../../6.plugin"; import { isSupportCss3, isIE, getIEVersion } from "../../platform/web"; import { HorizontalAlign, VerticalAlign } from "../../constant"; -import { FlexCenterLayout, FlexHorizontalLayout, VerticalLayout, +import { + FlexCenterLayout, FlexHorizontalLayout, VerticalLayout, FlexVerticalLayout, TdLayout, InlineLayout, FloatHorizontalFillLayout, ResponsiveInlineLayout, InlineCenterAdaptLayout, FlexVerticalCenterAdapt, @@ -26,7 +27,7 @@ import { HalfButton } from "@/case"; // 1、支持flex的浏览器下使用flex布局 // 2、不支持flex的浏览器下使用inline布局 // 3、当列宽既需要自动列宽又需要自适应列宽时,inline布局也处理不了了。当横向出滚动条时使用table布局,不出滚动条时使用float布局 -let _isSupportFlex, _isSupportGrid; +let _isSupportFlex, _isSupportGrid, _isSupportSticky; function isSupportFlex() { if (!_isSupportFlex) { @@ -45,7 +46,7 @@ function isSupportGrid() { } // 判断浏览器是否支持sticky 属性 -const isSupportSticky = (function () { +const innerSupportSticky = function() { const vendorList = ["", "-webkit-", "-ms-", "-moz-", "-o-"], vendorListLength = vendorList.length, stickyElement = document.createElement("div"); @@ -57,7 +58,15 @@ const isSupportSticky = (function () { } return false; -}()); +}; + +// 判断浏览器是否支持sticky 属性 +const isSupportSticky = function() { + if (_isSupportSticky == null) { + _isSupportSticky = innerSupportSticky(); + } + return _isSupportSticky; +}; const configWidget = Plugin.configWidget; @@ -74,7 +83,7 @@ configWidget("bi.horizontal", ob => { } return extend({ - scrollx: true, + scrollx: true }, ob, { type: InlineLayout.xtype }); }); configWidget("bi.vertical", ob => { @@ -90,15 +99,15 @@ configWidget("bi.vertical", ob => { return { type: InlineLayout.xtype, horizontalAlign: ob.horizontalAlign, - items: [item], + items: [item] }; - }), + }) }); } if (ob.verticalAlign === VerticalAlign.Stretch) { if (isSupportFlex()) { return extend({ - horizontalAlign: HorizontalAlign.Stretch, + horizontalAlign: HorizontalAlign.Stretch }, ob, { type: FlexVerticalLayout.xtype }); } } @@ -128,12 +137,12 @@ configWidget("bi.inline", ob => { // 宽度是不是受限 if ((ob.scrollable !== true && ob.scrollx !== true) || ob.horizontalAlign === HorizontalAlign.Stretch) { return extend({ - verticalAlign: VerticalAlign.Top, + verticalAlign: VerticalAlign.Top }, ob, { type: FloatHorizontalFillLayout.xtype }); } return extend({ - horizontalAlign: HorizontalAlign.Stretch, + horizontalAlign: HorizontalAlign.Stretch }, ob, { type: TableAdaptLayout.xtype }); } if (Providers.getProvider(SystemProvider.xtype).getResponsiveMode()) { @@ -179,18 +188,18 @@ configWidget("bi.horizontal_adapt", ob => { // 主要出现在center_adapt或者horizontal_adapt的场景,或者主动设置horizontalAlign的场景 if (isAdapt) { return extend({ - horizontalAlign: HorizontalAlign.Center, + horizontalAlign: HorizontalAlign.Center }, ob, { type: TableAdaptLayout.xtype }); } if (supportFlex) { return extend({ horizontalAlign: HorizontalAlign.Center, - scrollx: false, + scrollx: false }, ob, { type: FlexHorizontalLayout.xtype }); } return extend({ - horizontalAlign: HorizontalAlign.Center, + horizontalAlign: HorizontalAlign.Center }, ob, { type: TableAdaptLayout.xtype }); }); @@ -210,14 +219,14 @@ configWidget("bi.horizontal_fill", ob => { return extend({ horizontalAlign: HorizontalAlign.Stretch, verticalAlign: VerticalAlign.Stretch, - scrollx: false, + scrollx: false }, ob, { type: FlexHorizontalLayout.xtype }); } if ((ob.horizontalAlign && ob.horizontalAlign !== HorizontalAlign.Stretch) || (ob.scrollable === true || ob.scrollx === true)) { // 宽度不受限,要用table布局 return extend({ horizontalAlign: HorizontalAlign.Stretch, - verticalAlign: VerticalAlign.Stretch, + verticalAlign: VerticalAlign.Stretch }, ob, { type: TableLayout.xtype }); } @@ -228,14 +237,14 @@ configWidget("bi.vertical_fill", ob => { return extend({ horizontalAlign: HorizontalAlign.Stretch, verticalAlign: VerticalAlign.Stretch, - scrolly: false, + scrolly: false }, ob, { type: FlexVerticalLayout.xtype }); } if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) { // 有滚动条,降级到table布局处理 return extend({}, ob, { type: TdLayout.xtype, - items: map(ob.items, (i, item) => [item]), + items: map(ob.items, (i, item) => [item]) }); } let hasAuto = false; @@ -258,12 +267,12 @@ configWidget("bi.vertical_fill", ob => { return extend({}, ob, { type: VTapeLayout.xtype }); }); configWidget("bi.horizontal_sticky", ob => { - if (!isSupportSticky) { + if (!isSupportSticky()) { return extend({ scrollx: true }, ob, { type: HorizontalFillLayout.xtype }); } }); configWidget("bi.vertical_sticky", ob => { - if (!isSupportSticky) { + if (!isSupportSticky()) { return extend({ scrolly: true }, ob, { type: VerticalFillLayout.xtype }); } });