Browse Source

Pull request #3589: update isSupportSticky()

Merge in VISUAL/fineui from ~DAILER/fineui:master to master

* commit 'c5a983481c82e6520731bebc84bdd6b21bd27e4f':
  update isSupportSticky()
research/test
Dailer-刘荣歆 1 year ago
parent
commit
b90b812c4d
  1. 58
      src/core/platform/web/config.js

58
src/core/platform/web/config.js

@ -1,24 +1,24 @@
// 工程配置 // 工程配置
!(function () { !(function() {
// 注册布局 // 注册布局
// adapt类布局优先级规则 // adapt类布局优先级规则
// 1、支持flex的浏览器下使用flex布局 // 1、支持flex的浏览器下使用flex布局
// 2、不支持flex的浏览器下使用inline布局 // 2、不支持flex的浏览器下使用inline布局
// 3、当列宽既需要自动列宽又需要自适应列宽时,inline布局也处理不了了。当横向出滚动条时使用table布局,不出滚动条时使用float布局 // 3、当列宽既需要自动列宽又需要自适应列宽时,inline布局也处理不了了。当横向出滚动条时使用table布局,不出滚动条时使用float布局
var _isSupportFlex, _isSupportGrid, _isSupportSticky; var _isSupportFlex, _isSupportGrid, _isSupportSticky;
var isSupportFlex = function () { var isSupportFlex = function() {
if (_isSupportFlex == null) { if (_isSupportFlex == null) {
_isSupportFlex = !!(BI.isSupportCss3 && BI.isSupportCss3("flex")); _isSupportFlex = !!(BI.isSupportCss3 && BI.isSupportCss3("flex"));
} }
return _isSupportFlex; return _isSupportFlex;
}; };
var isSupportGrid = function () { var isSupportGrid = function() {
if (_isSupportGrid == null) { if (_isSupportGrid == null) {
_isSupportGrid = !!(BI.isSupportCss3 && BI.isSupportCss3("grid")); _isSupportGrid = !!(BI.isSupportCss3 && BI.isSupportCss3("grid"));
} }
return _isSupportGrid; return _isSupportGrid;
}; };
var innerSupportSticky = function () { var innerSupportSticky = function() {
var vendorList = ["", "-webkit-", "-ms-", "-moz-", "-o-"], var vendorList = ["", "-webkit-", "-ms-", "-moz-", "-o-"],
vendorListLength = vendorList.length, vendorListLength = vendorList.length,
stickyElement = document.createElement("div"); stickyElement = document.createElement("div");
@ -31,13 +31,13 @@
return false; return false;
}; };
// 判断浏览器是否支持sticky 属性 // 判断浏览器是否支持sticky 属性
var isSupportSticky = function () { var isSupportSticky = function() {
if (_isSupportSticky == null) { if (_isSupportSticky == null) {
_isSupportSticky = innerSupportSticky(); _isSupportSticky = innerSupportSticky();
} }
return _isSupportSticky; return _isSupportSticky;
}; };
BI.Plugin.configWidget("bi.horizontal", function (ob) { BI.Plugin.configWidget("bi.horizontal", function(ob) {
var supportFlex = isSupportFlex(); var supportFlex = isSupportFlex();
// // 在横向自适应场景下我们需要使用table的自适应撑出滚动条的特性(flex处理不了这种情况) // // 在横向自适应场景下我们需要使用table的自适应撑出滚动条的特性(flex处理不了这种情况)
// // 主要出现在center_adapt或者horizontal_adapt的场景,或者主动设置horizontalAlign的场景 // // 主要出现在center_adapt或者horizontal_adapt的场景,或者主动设置horizontalAlign的场景
@ -51,7 +51,7 @@
scrollx: true scrollx: true
}, ob, { type: "bi.inline" }); }, ob, { type: "bi.inline" });
}); });
BI.Plugin.configWidget("bi.vertical", function (ob) { BI.Plugin.configWidget("bi.vertical", function(ob) {
if (ob.horizontalAlign === BI.HorizontalAlign.Left || ob.horizontalAlign === BI.HorizontalAlign.Right) { if (ob.horizontalAlign === BI.HorizontalAlign.Left || ob.horizontalAlign === BI.HorizontalAlign.Right) {
if (isSupportFlex()) { if (isSupportFlex()) {
return BI.extend({}, ob, { type: "bi.flex_vertical" }); return BI.extend({}, ob, { type: "bi.flex_vertical" });
@ -59,7 +59,7 @@
return BI.extend({}, ob, { return BI.extend({}, ob, {
horizontalAlign: BI.HorizontalAlign.Stretch, horizontalAlign: BI.HorizontalAlign.Stretch,
type: "bi.vertical", type: "bi.vertical",
items: BI.map(ob.items, function (i, item) { items: BI.map(ob.items, function(i, item) {
return { return {
type: "bi.inline", type: "bi.inline",
horizontalAlign: ob.horizontalAlign, horizontalAlign: ob.horizontalAlign,
@ -77,7 +77,7 @@
} }
return ob; return ob;
}); });
BI.Plugin.configWidget("bi.inline", function (ob) { BI.Plugin.configWidget("bi.inline", function(ob) {
// 当列宽既需要自动列宽又需要自适应列宽时,inline布局也处理不了了,降级table处理吧 // 当列宽既需要自动列宽又需要自适应列宽时,inline布局也处理不了了,降级table处理吧
var hasAutoAndFillColumnSize = false; var hasAutoAndFillColumnSize = false;
if (ob.columnSize && ob.columnSize.length > 0) { if (ob.columnSize && ob.columnSize.length > 0) {
@ -86,7 +86,7 @@
} }
} else { } else {
var hasAuto = false, hasFill = false; var hasAuto = false, hasFill = false;
BI.each(ob.items, function (i, item) { BI.each(ob.items, function(i, item) {
if (item.width === "fill") { if (item.width === "fill") {
hasFill = true; hasFill = true;
} else if (BI.isNull(item.width) || item.width === "" || item.width === "auto") { } else if (BI.isNull(item.width) || item.width === "" || item.width === "auto") {
@ -112,7 +112,7 @@
} }
return ob; return ob;
}); });
BI.Plugin.configWidget("bi.center_adapt", function (ob) { BI.Plugin.configWidget("bi.center_adapt", function(ob) {
var supportFlex = isSupportFlex(); var supportFlex = isSupportFlex();
// var isAdapt = !ob.horizontalAlign || ob.horizontalAlign === BI.HorizontalAlign.Center || ob.horizontalAlign === BI.HorizontalAlign.Stretch; // var isAdapt = !ob.horizontalAlign || ob.horizontalAlign === BI.HorizontalAlign.Center || ob.horizontalAlign === BI.HorizontalAlign.Stretch;
// if (!isAdapt || justOneItem) { // if (!isAdapt || justOneItem) {
@ -123,7 +123,7 @@
// } // }
// return ob; // return ob;
}); });
BI.Plugin.configWidget("bi.vertical_adapt", function (ob) { BI.Plugin.configWidget("bi.vertical_adapt", function(ob) {
var supportFlex = isSupportFlex(); var supportFlex = isSupportFlex();
// var isAdapt = ob.horizontalAlign === BI.HorizontalAlign.Center || ob.horizontalAlign === BI.HorizontalAlign.Stretch; // var isAdapt = ob.horizontalAlign === BI.HorizontalAlign.Center || ob.horizontalAlign === BI.HorizontalAlign.Stretch;
// if (!isAdapt || justOneItem) { // if (!isAdapt || justOneItem) {
@ -134,7 +134,7 @@
// } // }
// return ob; // return ob;
}); });
BI.Plugin.configWidget("bi.horizontal_adapt", function (ob) { BI.Plugin.configWidget("bi.horizontal_adapt", function(ob) {
var justOneItem = (ob.items && ob.items.length <= 1); var justOneItem = (ob.items && ob.items.length <= 1);
var isAdapt = !ob.horizontalAlign || ob.horizontalAlign === BI.HorizontalAlign.Center || ob.horizontalAlign === BI.HorizontalAlign.Stretch; var isAdapt = !ob.horizontalAlign || ob.horizontalAlign === BI.HorizontalAlign.Center || ob.horizontalAlign === BI.HorizontalAlign.Stretch;
var verticalAlignTop = !ob.verticalAlign || ob.verticalAlign === BI.VerticalAlign.TOP; var verticalAlignTop = !ob.verticalAlign || ob.verticalAlign === BI.VerticalAlign.TOP;
@ -159,7 +159,7 @@
horizontalAlign: BI.HorizontalAlign.Center horizontalAlign: BI.HorizontalAlign.Center
}, ob, { type: "bi.table_adapt" }); }, ob, { type: "bi.table_adapt" });
}); });
BI.Plugin.configWidget("bi.horizontal_float", function (ob) { BI.Plugin.configWidget("bi.horizontal_float", function(ob) {
if (isSupportFlex()) { if (isSupportFlex()) {
return BI.extend({}, ob, { type: "bi.flex_horizontal_adapt" }); return BI.extend({}, ob, { type: "bi.flex_horizontal_adapt" });
} }
@ -169,7 +169,7 @@
return ob; return ob;
}); });
BI.Plugin.configWidget("bi.horizontal_fill", function (ob) { BI.Plugin.configWidget("bi.horizontal_fill", function(ob) {
if (isSupportFlex()) { if (isSupportFlex()) {
return BI.extend({ return BI.extend({
horizontalAlign: BI.HorizontalAlign.Stretch, horizontalAlign: BI.HorizontalAlign.Stretch,
@ -186,7 +186,7 @@
} }
return BI.extend({}, ob, { type: "bi.horizontal_float_fill" }); return BI.extend({}, ob, { type: "bi.horizontal_float_fill" });
}); });
BI.Plugin.configWidget("bi.vertical_fill", function (ob) { BI.Plugin.configWidget("bi.vertical_fill", function(ob) {
if (isSupportFlex()) { if (isSupportFlex()) {
return BI.extend({ return BI.extend({
horizontalAlign: BI.HorizontalAlign.Stretch, horizontalAlign: BI.HorizontalAlign.Stretch,
@ -198,7 +198,7 @@
// 有滚动条,降级到table布局处理 // 有滚动条,降级到table布局处理
return BI.extend({}, ob, { return BI.extend({}, ob, {
type: "bi.td", type: "bi.td",
items: BI.map(ob.items, function (i, item) { items: BI.map(ob.items, function(i, item) {
return [item]; return [item];
}) })
}); });
@ -209,7 +209,7 @@
hasAuto = true; hasAuto = true;
} }
} else { } else {
BI.each(ob.items, function (i, item) { BI.each(ob.items, function(i, item) {
if (BI.isNull(item.height) || item.height === "") { if (BI.isNull(item.height) || item.height === "") {
hasAuto = true; hasAuto = true;
} }
@ -221,18 +221,18 @@
} }
return BI.extend({}, ob, { type: "bi.vtape" }); return BI.extend({}, ob, { type: "bi.vtape" });
}); });
BI.Plugin.configWidget("bi.horizontal_sticky", function (ob) { BI.Plugin.configWidget("bi.horizontal_sticky", function(ob) {
if (!isSupportSticky) { if (!isSupportSticky()) {
return BI.extend({ scrollx: true }, ob, { type: "bi.horizontal_fill" }); return BI.extend({ scrollx: true }, ob, { type: "bi.horizontal_fill" });
} }
}); });
BI.Plugin.configWidget("bi.vertical_sticky", function (ob) { BI.Plugin.configWidget("bi.vertical_sticky", function(ob) {
if (!isSupportSticky) { if (!isSupportSticky()) {
return BI.extend({ scrolly: true }, ob, { type: "bi.vertical_fill" }); return BI.extend({ scrolly: true }, ob, { type: "bi.vertical_fill" });
} }
}); });
BI.Plugin.configWidget("bi.left_right_vertical_adapt", function (ob) { BI.Plugin.configWidget("bi.left_right_vertical_adapt", function(ob) {
if (isSupportFlex()) { if (isSupportFlex()) {
// IE下其实也是可以使用flex布局的,只要排除掉出现滚动条的情况 // IE下其实也是可以使用flex布局的,只要排除掉出现滚动条的情况
// if (!BI.isIE() || (ob.scrollable !== true && ob.scrolly !== true)) { // if (!BI.isIE() || (ob.scrollable !== true && ob.scrolly !== true)) {
@ -241,7 +241,7 @@
} }
return ob; return ob;
}); });
BI.Plugin.configWidget("bi.flex_horizontal", function (ob) { BI.Plugin.configWidget("bi.flex_horizontal", function(ob) {
if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) { if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) {
if (ob.hgap > 0 || ob.lgap > 0 || ob.rgap > 0) { if (ob.hgap > 0 || ob.lgap > 0 || ob.rgap > 0) {
if (BI.Providers.getProvider("bi.provider.system").getResponsiveMode()) { if (BI.Providers.getProvider("bi.provider.system").getResponsiveMode()) {
@ -254,7 +254,7 @@
return BI.extend({}, ob, { type: "bi.responsive_flex_horizontal" }); return BI.extend({}, ob, { type: "bi.responsive_flex_horizontal" });
} }
}); });
BI.Plugin.configWidget("bi.flex_vertical", function (ob) { BI.Plugin.configWidget("bi.flex_vertical", function(ob) {
if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) { if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) {
if (ob.hgap > 0 || ob.lgap > 0 || ob.rgap > 0) { if (ob.hgap > 0 || ob.lgap > 0 || ob.rgap > 0) {
return BI.extend({}, ob, { type: "bi.flex_scrollable_vertical" }); return BI.extend({}, ob, { type: "bi.flex_scrollable_vertical" });
@ -262,28 +262,28 @@
} }
}); });
BI.Plugin.configWidget("bi.table", function (ob) { BI.Plugin.configWidget("bi.table", function(ob) {
if (!isSupportGrid()) { if (!isSupportGrid()) {
return BI.extend({}, ob, { type: "bi.td" }); return BI.extend({}, ob, { type: "bi.td" });
} }
return ob; return ob;
}); });
BI.Plugin.configWidget("bi.radio", function (ob) { BI.Plugin.configWidget("bi.radio", function(ob) {
if (BI.isIE() && BI.getIEVersion() <= 9) { if (BI.isIE() && BI.getIEVersion() <= 9) {
return BI.extend({}, ob, { type: "bi.image_radio" }); return BI.extend({}, ob, { type: "bi.image_radio" });
} }
return ob; return ob;
}); });
BI.Plugin.configWidget("bi.checkbox", function (ob) { BI.Plugin.configWidget("bi.checkbox", function(ob) {
if (BI.isIE() && BI.getIEVersion() <= 9) { if (BI.isIE() && BI.getIEVersion() <= 9) {
return BI.extend({}, ob, { type: "bi.image_checkbox" }); return BI.extend({}, ob, { type: "bi.image_checkbox" });
} }
return ob; return ob;
}); });
BI.Plugin.configWidget("bi.half_icon_button", function (ob) { BI.Plugin.configWidget("bi.half_icon_button", function(ob) {
if (BI.isIE() && BI.getIEVersion() < 9) { if (BI.isIE() && BI.getIEVersion() < 9) {
return ob; return ob;
} }

Loading…
Cancel
Save