Skip to content

Commit 46f4ada

Browse files
committed
update container height on margin change
1 parent fca6c81 commit 46f4ada

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/App.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333
<input type="checkbox" v-model="preventCollision"/> Prevent Collision
3434
<div style="margin-top: 10px;margin-bottom: 10px;">
3535
Row Height: <input type="number" v-model="rowHeight"/> Col nums: <input type="number" v-model="colNum"/>
36+
Margin x: <input type="number" v-model="marginX"/> Margin y: <input type="number" v-model="marginY"/>
3637
</div>
3738
<grid-layout
39+
:margin="[parseInt(marginX), parseInt(marginY)]"
3840
:layout.sync="layout"
3941
:col-num="parseInt(colNum)"
4042
:row-height="rowHeight"
@@ -150,7 +152,9 @@
150152
preventCollision: false,
151153
rowHeight: 30,
152154
colNum: 12,
153-
index: 0
155+
index: 0,
156+
marginX: 10,
157+
marginY: 10,
154158
}
155159
},
156160
mounted: function () {

src/components/GridLayout.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@
247247
maxRows: function() {
248248
this.eventBus.$emit("setMaxRows", this.maxRows);
249249
},
250+
margin() {
251+
this.updateHeight();
252+
}
250253
},
251254
methods: {
252255
layoutUpdate() {
@@ -292,7 +295,10 @@
292295
},
293296
containerHeight: function () {
294297
if (!this.autoSize) return;
295-
return bottom(this.layout) * (this.rowHeight + this.margin[1]) + this.margin[1] + 'px';
298+
// console.log("bottom: " + bottom(this.layout))
299+
// console.log("rowHeight + margins: " + (this.rowHeight + this.margin[1]) + this.margin[1])
300+
const containerHeight = bottom(this.layout) * (this.rowHeight + this.margin[1]) + this.margin[1] + 'px';
301+
return containerHeight;
296302
},
297303
dragEvent: function (eventName, id, x, y, h, w) {
298304
//console.log(eventName + " id=" + id + ", x=" + x + ", y=" + y);

0 commit comments

Comments
 (0)