fix(Layout): gutter calculation (#6197)

* Revert "fix(Layout): outside of the screen after setting gutter (#6143)"

This reverts commit a460425b26.

* fix(Layout): gutter calculation

* test: fix snapshot
This commit is contained in:
neverland
2020-05-02 16:43:52 +08:00
committed by GitHub
parent 4adefe5605
commit 9a4927ac05
6 changed files with 112 additions and 31 deletions
+6 -19
View File
@@ -16,28 +16,15 @@ export default createComponent({
},
computed: {
gutter() {
return (this.parent && Number(this.parent.gutter)) || 0;
},
style() {
const { index, gutter } = this;
if (gutter) {
const count = this.parent.children.length;
const padding = (gutter * (count - 1)) / count;
if (index === 0) {
return { paddingRight: `${padding}px` };
}
if (index === count - 1) {
return { paddingLeft: `${padding}px` };
}
const { index } = this;
const { spaces } = this.parent || {};
if (spaces && spaces[index]) {
const { left, right } = spaces[index];
return {
paddingLeft: `${padding / 2}px`,
paddingRight: `${padding / 2}px`,
paddingLeft: left ? `${left}px` : null,
paddingRight: right ? `${right}px` : null,
};
}
},