Skip to content

Commit bada5b9

Browse files
ygj6gmsa
andauthored
Fix jbaysolutions#478: Grid items overlapping when using this.$parent.autoSize()
* fix issue 478 in vue3 * Update src/components/GridItem.vue Co-authored-by: Gustavo Santos <[email protected]>
1 parent 561f1ab commit bada5b9

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/components/GridItem.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -716,16 +716,22 @@ import { getDocumentDir } from "../helpers/DOM"
716716
* Given a height and width in pixel values, calculate grid units.
717717
* @param {Number} height Height in pixels.
718718
* @param {Number} width Width in pixels.
719+
* @param {Boolean} autoSizeFlag function autoSize identifier.
719720
* @return {Object} w, h as grid units.
720721
*/
721-
calcWH(height: number, width: number) {
722+
calcWH(height: number, width: number, autoSizeFlag = false) {
722723
const colWidth = this.calcColWidth();
723724
724725
// width = colWidth * w - (margin * (w - 1))
725726
// ...
726727
// w = (width + margin) / (colWidth + margin)
727728
let w = Math.round((width + this.margin[0]) / (colWidth + this.margin[0]));
728-
let h = Math.round((height + this.margin[1]) / (this.rowHeight + this.margin[1]));
729+
let h = 0;
730+
if (!autoSizeFlag) {
731+
h = Math.round((height + this.margin[1]) / (this.rowHeight + this.margin[1]));
732+
} else {
733+
h = Math.ceil((height + this.margin[1]) / (this.rowHeight + this.margin[1]));
734+
}
729735
730736
// Capping
731737
w = Math.max(Math.min(w, this.cols - this.innerX), 0);
@@ -819,7 +825,7 @@ import { getDocumentDir } from "../helpers/DOM"
819825
this.previousH = this.innerH;
820826
821827
let newSize=this.$slots.default[0].elm.getBoundingClientRect();
822-
let pos = this.calcWH(newSize.height, newSize.width);
828+
let pos = this.calcWH(newSize.height, newSize.width, true);
823829
if (pos.w < this.minW) {
824830
pos.w = this.minW;
825831
}

0 commit comments

Comments
 (0)