Browse Source

Merge pull request #34583 in DEC/fineui from master to feature/x

* commit '2c3bf54dd696dc3bc240ed813023a67738e1dc8d':
  feature: 布局优化写法,提供系统配置
  feature: 布局优化写法,提供系统配置
es6
superman 3 years ago
parent
commit
4e6f33bc0f
  1. 11
      src/core/system.js
  2. 32
      src/core/wrapper/layout.js

11
src/core/system.js

@ -7,6 +7,7 @@
!(function () {
var system = {
dependencies: {},
layoutOptimize: false,
responsiveMode: false,
workerMode: false,
size: {
@ -24,7 +25,7 @@
// 具体尺寸还没定,先写着
var sizeMap = {
"S": 10,
"M" : 20,
"M": 20,
"L": 24
};
@ -44,6 +45,10 @@
system.workerMode = !!mode;
};
this.setLayoutOptimize = function (layoutOptimize) {
system.layoutOptimize = layoutOptimize;
};
this.addDependency = function (moduleId, minVersion, maxVersion) {
system.dependencies[moduleId] = {
min: minVersion,
@ -77,6 +82,10 @@
return system.workerMode;
},
getLayoutOptimize: function () {
return system.layoutOptimize;
},
getDependencies: function () {
return system.dependencies;
}

32
src/core/wrapper/layout.js

@ -16,7 +16,7 @@ BI.Layout = BI.inherit(BI.Widget, {
scrolly: false, // true, false
items: [],
innerHgap: 0,
innerVgap: 0,
innerVgap: 0
};
},
@ -293,22 +293,40 @@ BI.Layout = BI.inherit(BI.Widget, {
},
_optimiseItemLgap: function (item) {
return item.lgap || 0;
if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) {
return ((!item.type && item.el) ? item.lgap : item._lgap) || 0;
}
return (item._lgap || 0) + (item.lgap || 0);
},
_optimiseItemRgap: function (item) {
return item.rgap || 0;
if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) {
return ((!item.type && item.el) ? item.rgap : item._rgap) || 0;
}
return (item._rgap || 0) + (item.rgap || 0);
},
_optimiseItemTgap: function (item) {
return item.tgap || 0;
if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) {
return ((!item.type && item.el) ? item.tgap : item._tgap) || 0;
}
return (item._tgap || 0) + (item.tgap || 0);
},
_optimiseItemBgap: function (item) {
return item.bgap || 0;
if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) {
return ((!item.type && item.el) ? item.bgap : item._bgap) || 0;
}
return (item._bgap || 0) + (item.bgap || 0);
},
_optimiseItemHgap: function (item) {
return item.hgap || 0;
if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) {
return ((!item.type && item.el) ? item.hgap : item._hgap) || 0;
}
return (item._hgap || 0) + (item.hgap || 0);
},
_optimiseItemVgap: function (item) {
return item.vgap || 0;
if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) {
return ((!item.type && item.el) ? item.vgap : item._vgap) || 0;
}
return (item._vgap || 0) + (item.vgap || 0);
},
_handleGap: function (w, item, hIndex, vIndex) {

Loading…
Cancel
Save