Skip to content

Commit fd0b8c6

Browse files
authored
Fix #478: Grid items overlapping when using this.$parent.autoSize()
1 parent e1ad125 commit fd0b8c6

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/components/GridItem.vue

+9-3
Original file line numberDiff line numberDiff line change
@@ -727,16 +727,22 @@
727727
* Given a height and width in pixel values, calculate grid units.
728728
* @param {Number} height Height in pixels.
729729
* @param {Number} width Width in pixels.
730+
* @param {Boolean} autoSizeFlag function autoSize identifier.
730731
* @return {Object} w, h as grid units.
731732
*/
732-
calcWH(height, width) {
733+
calcWH(height, width, autoSizeFlag = false) {
733734
const colWidth = this.calcColWidth();
734735
735736
// width = colWidth * w - (margin * (w - 1))
736737
// ...
737738
// w = (width + margin) / (colWidth + margin)
738739
let w = Math.round((width + this.margin[0]) / (colWidth + this.margin[0]));
739-
let h = Math.round((height + this.margin[1]) / (this.rowHeight + this.margin[1]));
740+
let h = 0;
741+
if (!autoSizeFlag) {
742+
h = Math.round((height + this.margin[1]) / (this.rowHeight + this.margin[1]));
743+
} else {
744+
h = Math.ceil((height + this.margin[1]) / (this.rowHeight + this.margin[1]));
745+
}
740746
741747
// Capping
742748
w = Math.max(Math.min(w, this.cols - this.innerX), 0);
@@ -843,7 +849,7 @@
843849
this.previousH = this.innerH;
844850
845851
let newSize=this.$slots.default[0].elm.getBoundingClientRect();
846-
let pos = this.calcWH(newSize.height, newSize.width);
852+
let pos = this.calcWH(newSize.height, newSize.width, true);
847853
if (pos.w < this.minW) {
848854
pos.w = this.minW;
849855
}

0 commit comments

Comments
 (0)