Browse Source

整理代码

es6
guy 3 years ago
parent
commit
52f1c6621b
  1. 15
      src/core/wrapper/layout/float/float.absolute.horizontal.js
  2. 9
      src/core/wrapper/layout/float/float.absolute.vertical.js
  3. 12
      src/less/core/wrapper/float.absolute.less

15
src/core/wrapper/layout/float/float.absolute.horizontal.js

@ -31,26 +31,29 @@ BI.FloatAbsoluteHorizontalLayout = BI.inherit(BI.Layout, {
}, },
hgap: "50%", hgap: "50%",
vgap: o.vgap, vgap: o.vgap,
lgap: o.lgap,
rgap: o.rgap,
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap bgap: o.bgap,
// lgap和rgap不传的话内部不会设置left和right
lgap: o.lgap,
rgap: o.rgap
}; };
}, },
_formatItems: function (items) { _formatItems: function (items) {
if (this.options.horizontalAlign !== BI.HorizontalAlign.Center) { var o = this.options;
if (o.horizontalAlign === BI.HorizontalAlign.Left) {
return items; return items;
} }
var cls = o.horizontalAlign === BI.HorizontalAlign.Right ? "bi-abs-r-x-item" : "bi-abs-c-x-item";
return BI.map(items, function (i, item) { return BI.map(items, function (i, item) {
if (!item || BI.isEmptyObject(item)) { if (!item || BI.isEmptyObject(item)) {
return item; return item;
} }
var el = BI.stripEL(item); var el = BI.stripEL(item);
if (BI.isWidget(el)) { if (BI.isWidget(el)) {
el.element.addClass("bi-abs-c-x-item"); el.element.addClass(cls);
} else { } else {
el.cls = (el.cls || "") + "bi-abs-c-x-item"; el.cls = (el.cls || "") + cls;
} }
return item; return item;
}); });

9
src/core/wrapper/layout/float/float.absolute.vertical.js

@ -33,24 +33,27 @@ BI.FloatAbsoluteVerticalLayout = BI.inherit(BI.Layout, {
hgap: o.hgap, hgap: o.hgap,
lgap: o.lgap, lgap: o.lgap,
rgap: o.rgap, rgap: o.rgap,
// tgap和bgap不传的话内部不会设置top和bottom
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap bgap: o.bgap
}; };
}, },
_formatItems: function (items) { _formatItems: function (items) {
if (this.options.verticalAlign !== BI.VerticalAlign.Middle) { var o = this.options;
if (o.verticalAlign === BI.VerticalAlign.Top) {
return items; return items;
} }
var cls = o.verticalAlign === BI.VerticalAlign.Bottom ? "bi-abs-b-y-item" : "bi-abs-c-y-item";
return BI.map(items, function (i, item) { return BI.map(items, function (i, item) {
if (!item || BI.isEmptyObject(item)) { if (!item || BI.isEmptyObject(item)) {
return item; return item;
} }
var el = BI.stripEL(item); var el = BI.stripEL(item);
if (BI.isWidget(el)) { if (BI.isWidget(el)) {
el.element.addClass("bi-abs-c-y-item"); el.element.addClass(cls);
} else { } else {
el.cls = (el.cls || "") + "bi-abs-c-y-item"; el.cls = (el.cls || "") + cls;
} }
return item; return item;
}); });

12
src/less/core/wrapper/float.absolute.less

@ -24,4 +24,14 @@
-webkit-transform: translate(-50%, -50%); /* Safari 和 Chrome */ -webkit-transform: translate(-50%, -50%); /* Safari 和 Chrome */
-o-transform: translate(-50%, -50%); /* Opera */ -o-transform: translate(-50%, -50%); /* Opera */
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
} }
.bi-abs-b-y-item {
bottom: 0;
margin-top: auto;
}
.bi-abs-r-x-item {
right: 0;
margin-left: auto;
}

Loading…
Cancel
Save