|
|
|
@ -292,6 +292,25 @@ BI.Layout = BI.inherit(BI.Widget, {
|
|
|
|
|
return (gap > 0 && gap < 1) ? (gap * 100).toFixed(1) + "%" : gap / BI.pixRatio + BI.pixUnit; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
_optimiseItemLgap: function (item) { |
|
|
|
|
return item.lgap || 0; |
|
|
|
|
}, |
|
|
|
|
_optimiseItemRgap: function (item) { |
|
|
|
|
return item.rgap || 0; |
|
|
|
|
}, |
|
|
|
|
_optimiseItemTgap: function (item) { |
|
|
|
|
return item.tgap || 0; |
|
|
|
|
}, |
|
|
|
|
_optimiseItemBgap: function (item) { |
|
|
|
|
return item.bgap || 0; |
|
|
|
|
}, |
|
|
|
|
_optimiseItemHgap: function (item) { |
|
|
|
|
return item.hgap || 0; |
|
|
|
|
}, |
|
|
|
|
_optimiseItemVgap: function (item) { |
|
|
|
|
return item.vgap || 0; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
_handleGap: function (w, item, hIndex, vIndex) { |
|
|
|
|
var o = this.options; |
|
|
|
|
var innerLgap, innerRgap, innerTgap, innerBgap; |
|
|
|
@ -304,26 +323,26 @@ BI.Layout = BI.inherit(BI.Widget, {
|
|
|
|
|
innerTgap = vIndex === 0 ? o.innerVgap : 0; |
|
|
|
|
innerBgap = vIndex === o.items.length - 1 ? o.innerVgap : 0; |
|
|
|
|
} |
|
|
|
|
if (o.vgap + o.tgap + innerTgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { |
|
|
|
|
var top = ((BI.isNull(vIndex) || vIndex === 0) ? o.vgap : 0) + o.tgap + innerTgap + (item.tgap || 0) + (item.vgap || 0); |
|
|
|
|
if (o.vgap + o.tgap + innerTgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item) !== 0) { |
|
|
|
|
var top = ((BI.isNull(vIndex) || vIndex === 0) ? o.vgap : 0) + o.tgap + innerTgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item); |
|
|
|
|
w.element.css({ |
|
|
|
|
"margin-top": this._optimiseGap(top) |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (o.hgap + o.lgap + innerLgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { |
|
|
|
|
var left = ((BI.isNull(hIndex) || hIndex === 0) ? o.hgap : 0) + o.lgap + innerLgap + (item.lgap || 0) + (item.hgap || 0); |
|
|
|
|
if (o.hgap + o.lgap + innerLgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item) !== 0) { |
|
|
|
|
var left = ((BI.isNull(hIndex) || hIndex === 0) ? o.hgap : 0) + o.lgap + innerLgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item); |
|
|
|
|
w.element.css({ |
|
|
|
|
"margin-left": this._optimiseGap(left) |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (o.hgap + o.rgap + innerRgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { |
|
|
|
|
var right = o.hgap + o.rgap + innerRgap + (item.rgap || 0) + (item.hgap || 0); |
|
|
|
|
if (o.hgap + o.rgap + innerRgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item) !== 0) { |
|
|
|
|
var right = o.hgap + o.rgap + innerRgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item); |
|
|
|
|
w.element.css({ |
|
|
|
|
"margin-right": this._optimiseGap(right) |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (o.vgap + o.bgap + innerBgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { |
|
|
|
|
var bottom = o.vgap + o.bgap + innerBgap + (item.bgap || 0) + (item.vgap || 0); |
|
|
|
|
if (o.vgap + o.bgap + innerBgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item) !== 0) { |
|
|
|
|
var bottom = o.vgap + o.bgap + innerBgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); |
|
|
|
|
w.element.css({ |
|
|
|
|
"margin-bottom": this._optimiseGap(bottom) |
|
|
|
|
}); |
|
|
|
@ -337,27 +356,27 @@ BI.Layout = BI.inherit(BI.Widget, {
|
|
|
|
|
innerLgap = innerRgap = o.innerHgap; |
|
|
|
|
innerTgap = index === 0 ? o.innerVgap : 0; |
|
|
|
|
innerBgap = index === o.items.length - 1 ? o.innerVgap : 0; |
|
|
|
|
if (o.vgap + o.tgap + innerTgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { |
|
|
|
|
var top = (index === 0 ? o.vgap : 0) + (index === 0 ? o.tgap : 0) + innerTgap + (item.tgap || 0) + (item.vgap || 0); |
|
|
|
|
if (o.vgap + o.tgap + innerTgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item) !== 0) { |
|
|
|
|
var top = (index === 0 ? o.vgap : 0) + (index === 0 ? o.tgap : 0) + innerTgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item); |
|
|
|
|
w.element.css({ |
|
|
|
|
"margin-top": this._optimiseGap(top) |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (o.hgap + o.lgap + innerLgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { |
|
|
|
|
var left = o.hgap + o.lgap + innerLgap + (item.lgap || 0) + (item.hgap || 0); |
|
|
|
|
if (o.hgap + o.lgap + innerLgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item) !== 0) { |
|
|
|
|
var left = o.hgap + o.lgap + innerLgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item); |
|
|
|
|
w.element.css({ |
|
|
|
|
"margin-left": this._optimiseGap(left) |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (o.hgap + o.rgap + innerRgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { |
|
|
|
|
var right = o.hgap + o.rgap + innerRgap + (item.rgap || 0) + (item.hgap || 0); |
|
|
|
|
if (o.hgap + o.rgap + innerRgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item) !== 0) { |
|
|
|
|
var right = o.hgap + o.rgap + innerRgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item); |
|
|
|
|
w.element.css({ |
|
|
|
|
"margin-right": this._optimiseGap(right) |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
// 这里的代码是关键
|
|
|
|
|
if (o.vgap + o.hgap + o.bgap + innerBgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { |
|
|
|
|
var bottom = (index === o.items.length - 1 ? o.vgap : o.hgap) + (index === o.items.length - 1 ? o.bgap : 0) + innerBgap + (item.bgap || 0) + (item.vgap || 0); |
|
|
|
|
if (o.vgap + o.hgap + o.bgap + innerBgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item) !== 0) { |
|
|
|
|
var bottom = (index === o.items.length - 1 ? o.vgap : o.hgap) + (index === o.items.length - 1 ? o.bgap : 0) + innerBgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); |
|
|
|
|
w.element.css({ |
|
|
|
|
"margin-bottom": this._optimiseGap(bottom) |
|
|
|
|
}); |
|
|
|
|