Browse Source

feature: 布局优化写法,提供系统配置

es6
guy 3 years ago
parent
commit
b2abf387d5
  1. 9
      src/core/system.js
  2. 20
      src/core/wrapper/layout.js

9
src/core/system.js

@ -7,6 +7,7 @@
!(function () { !(function () {
var system = { var system = {
dependencies: {}, dependencies: {},
layoutOptimize: false,
responsiveMode: false, responsiveMode: false,
workerMode: false, workerMode: false,
size: { size: {
@ -44,6 +45,10 @@
system.workerMode = !!mode; system.workerMode = !!mode;
}; };
this.setLayoutOptimize = function (layoutOptimize) {
system.layoutOptimize = layoutOptimize;
};
this.addDependency = function (moduleId, minVersion, maxVersion) { this.addDependency = function (moduleId, minVersion, maxVersion) {
system.dependencies[moduleId] = { system.dependencies[moduleId] = {
min: minVersion, min: minVersion,
@ -77,6 +82,10 @@
return system.workerMode; return system.workerMode;
}, },
getLayoutOptimize: function () {
return system.layoutOptimize;
},
getDependencies: function () { getDependencies: function () {
return system.dependencies; return system.dependencies;
} }

20
src/core/wrapper/layout.js

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

Loading…
Cancel
Save