Skip to content

Commit d9d3786

Browse files
authored
Merge pull request jbaysolutions#1 from mech01nc01/mech01nc01-patch-1
new function autoSize
2 parents a54bff5 + c1b5d9e commit d9d3786

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/GridItem.vue

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,45 @@
697697
},
698698
compact: function () {
699699
this.createStyle();
700+
},
701+
autoSize: function()
702+
{
703+
// ok here we want to calculate if a resize is needed
704+
this.previousW = this.innerW;
705+
this.previousH = this.innerH;
706+
707+
let newSize=this.$slots.default[0].elm.getBoundingClientRect();
708+
let pos = this.calcWH(newSize.height, newSize.width);
709+
if (pos.w < this.minW) {
710+
pos.w = this.minW;
711+
}
712+
if (pos.w > this.maxW) {
713+
pos.w = this.maxW;
714+
}
715+
if (pos.h < this.minH) {
716+
pos.h = this.minH;
717+
}
718+
if (pos.h > this.maxH) {
719+
pos.h = this.maxH;
720+
}
721+
722+
if (pos.h < 1) {
723+
pos.h = 1;
724+
}
725+
if (pos.w < 1) {
726+
pos.w = 1;
727+
}
728+
729+
// this.lastW = x; // basicly, this is copied from resizehandler, but shouldn't be needed
730+
// this.lastH = y;
731+
732+
if (this.innerW !== pos.w || this.innerH !== pos.h) {
733+
this.$emit("resize", this.i, pos.h, pos.w, newSize.height, newSize.width);
734+
}
735+
if (this.previousW !== pos.w || this.previousH !== pos.h) {
736+
this.$emit("resized", this.i, pos.h, pos.w, newSize.height, newSize.width);
737+
this.eventBus.$emit("resizeEvent", "resizeend", this.i, this.innerX, this.innerY, pos.h, pos.w);
738+
}
700739
}
701740
},
702741
}

0 commit comments

Comments
 (0)