Skip to content

Commit bcbf636

Browse files
author
luzhiqiang
committed
fix: wrong parent layout when GridItem is not the child of GridLayout
1 parent 2b4d6a2 commit bcbf636

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/components/GridItem.vue

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
default: 'a, button'
193193
},
194194
},
195-
inject: ["eventBus"],
195+
inject: ["eventBus", "layout"],
196196
data: function () {
197197
return {
198198
cols: 1,
@@ -296,22 +296,22 @@
296296
}
297297
},
298298
mounted: function () {
299-
this.cols = this.$parent.colNum;
300-
this.rowHeight = this.$parent.rowHeight;
301-
this.containerWidth = this.$parent.width !== null ? this.$parent.width : 100;
302-
this.margin = this.$parent.margin !== undefined ? this.$parent.margin : [10, 10];
303-
this.maxRows = this.$parent.maxRows;
299+
this.cols = this.layout.colNum;
300+
this.rowHeight = this.layout.rowHeight;
301+
this.containerWidth = this.layout.width !== null ? this.layout.width : 100;
302+
this.margin = this.layout.margin !== undefined ? this.layout.margin : [10, 10];
303+
this.maxRows = this.layout.maxRows;
304304
if (this.isDraggable === null) {
305-
this.draggable = this.$parent.isDraggable;
305+
this.draggable = this.layout.isDraggable;
306306
} else {
307307
this.draggable = this.isDraggable;
308308
}
309309
if (this.isResizable === null) {
310-
this.resizable = this.$parent.isResizable;
310+
this.resizable = this.layout.isResizable;
311311
} else {
312312
this.resizable = this.isResizable;
313313
}
314-
this.useCssTransforms = this.$parent.useCssTransforms;
314+
this.useCssTransforms = this.layout.useCssTransforms;
315315
this.createStyle();
316316
},
317317
watch: {
@@ -412,7 +412,7 @@
412412
return navigator.userAgent.toLowerCase().indexOf("android") !== -1;
413413
},
414414
renderRtl() {
415-
return (this.$parent.isMirrored) ? !this.rtl : this.rtl;
415+
return (this.layout.isMirrored) ? !this.rtl : this.rtl;
416416
},
417417
resizableHandleClass() {
418418
if (this.renderRtl) {

src/components/GridLayout.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
name: "GridLayout",
3232
provide() {
3333
return {
34-
eventBus: null
34+
eventBus: null,
35+
layout: this
3536
}
3637
},
3738
components: {

0 commit comments

Comments
 (0)