Browse Source

inline布局支持用calc计算fill宽度

es6
guy 4 years ago
parent
commit
d5b4587092
  1. 11
      src/core/wrapper/layout/adapt/inline.center.js
  2. 11
      src/core/wrapper/layout/adapt/inline.horizontal.js
  3. 11
      src/core/wrapper/layout/adapt/inline.vertical.js

11
src/core/wrapper/layout/adapt/inline.center.js

@ -43,6 +43,17 @@ BI.InlineCenterAdaptLayout = BI.inherit(BI.Layout, {
"vertical-align": o.verticalAlign "vertical-align": o.verticalAlign
}); });
w.element.addClass("i-c-a-item"); w.element.addClass("i-c-a-item");
if (o.columnSize[i] === "fill") {
var left = o.hgap + (item.lgap || 0) + (item.hgap || 0),
right = o.hgap + (item.rgap || 0) + (item.hgap || 0);
for (var k = 0; k < i; k++) {
left += o.hgap + o.lgap + o.rgap + o.columnSize[k];
}
for (var k = i + 1; k < o.columnSize.length; k++) {
right += o.hgap + o.lgap + o.rgap + o.columnSize[k];
}
w.element.css("min-width", "calc(100% - " + ((left + right) / BI.pixRatio + BI.pixUnit) + ")");
}
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-top": (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit "margin-top": (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit

11
src/core/wrapper/layout/adapt/inline.horizontal.js

@ -43,6 +43,17 @@ BI.InlineHorizontalAdaptLayout = BI.inherit(BI.Layout, {
"vertical-align": o.verticalAlign "vertical-align": o.verticalAlign
}); });
w.element.addClass("i-h-a-item"); w.element.addClass("i-h-a-item");
if (o.columnSize[i] === "fill") {
var left = o.hgap + (item.lgap || 0) + (item.hgap || 0),
right = o.hgap + (item.rgap || 0) + (item.hgap || 0);
for (var k = 0; k < i; k++) {
left += o.hgap + o.lgap + o.rgap + o.columnSize[k];
}
for (var k = i + 1; k < o.columnSize.length; k++) {
right += o.hgap + o.lgap + o.rgap + o.columnSize[k];
}
w.element.css("min-width", "calc(100% - " + ((left + right) / BI.pixRatio + BI.pixUnit) + ")");
}
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-top": (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit "margin-top": (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit

11
src/core/wrapper/layout/adapt/inline.vertical.js

@ -43,6 +43,17 @@ BI.InlineVerticalAdaptLayout = BI.inherit(BI.Layout, {
"vertical-align": o.verticalAlign "vertical-align": o.verticalAlign
}); });
w.element.addClass("i-v-a-item"); w.element.addClass("i-v-a-item");
if (o.columnSize[i] === "fill") {
var left = o.hgap + (item.lgap || 0) + (item.hgap || 0),
right = o.hgap + (item.rgap || 0) + (item.hgap || 0);
for (var k = 0; k < i; k++) {
left += o.hgap + o.lgap + o.rgap + o.columnSize[k];
}
for (var k = i + 1; k < o.columnSize.length; k++) {
right += o.hgap + o.lgap + o.rgap + o.columnSize[k];
}
w.element.css("min-width", "calc(100% - " + ((left + right) / BI.pixRatio + BI.pixUnit) + ")");
}
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-top": (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit "margin-top": (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit

Loading…
Cancel
Save