Browse Source

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

es6
guy 3 years ago
parent
commit
b2abf387d5
  1. 11
      src/core/system.js
  2. 20
      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;
}

20
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,21 +293,39 @@ BI.Layout = BI.inherit(BI.Widget, {
},
_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;
},
_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;
},
_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;
},
_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;
},
_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;
},
_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;
},

Loading…
Cancel
Save