Skip to content

Commit d3b52cf

Browse files
Luis CarrerasLuis Carreras
authored andcommitted
restrict tile resizing interaction when max/min height and width are specified.
1 parent a54bff5 commit d3b52cf

File tree

1 file changed

+47
-29
lines changed

1 file changed

+47
-29
lines changed

src/GridItem.vue

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -338,43 +338,17 @@
338338
this.resizable = this.isResizable;
339339
},
340340
resizable: function () {
341-
var self = this;
342-
if (this.interactObj === null || this.interactObj === undefined) {
343-
this.interactObj = interact(this.$refs.item);
344-
}
345-
if (this.resizable) {
346-
var opts = {
347-
preserveAspectRatio: false,
348-
edges: {
349-
left: false,
350-
right: "." + this.resizableHandleClass,
351-
bottom: "." + this.resizableHandleClass,
352-
top: false
353-
},
354-
ignoreFrom: this.resizeIgnoreFrom
355-
};
356-
357-
this.interactObj.resizable(opts);
358-
if (!this.resizeEventSet) {
359-
this.resizeEventSet = true;
360-
this.interactObj
361-
.on('resizestart resizemove resizeend', function (event) {
362-
self.handleResize(event);
363-
});
364-
}
365-
} else {
366-
this.interactObj.resizable({
367-
enabled: false
368-
});
369-
}
341+
this.tryMakeResizable();
370342
},
371343
rowHeight: function () {
372344
this.createStyle();
373345
},
374346
cols: function () {
347+
this.tryMakeResizable();
375348
this.createStyle();
376349
},
377350
containerWidth: function () {
351+
this.tryMakeResizable();
378352
this.createStyle();
379353
},
380354
x: function (newVal) {
@@ -697,6 +671,50 @@
697671
},
698672
compact: function () {
699673
this.createStyle();
674+
},
675+
tryMakeResizable: function(){
676+
var self = this;
677+
if (this.interactObj === null || this.interactObj === undefined) {
678+
this.interactObj = interact(this.$refs.item);
679+
}
680+
if (this.resizable) {
681+
let maximum = this.calcPosition(0,0,this.maxW, this.maxH);
682+
let minimum = this.calcPosition(0,0, this.minW, this.minH);
683+
684+
var opts = {
685+
preserveAspectRatio: false,
686+
edges: {
687+
left: false,
688+
right: "." + this.resizableHandleClass,
689+
bottom: "." + this.resizableHandleClass,
690+
top: false
691+
},
692+
ignoreFrom: this.resizeIgnoreFrom,
693+
restrictSize: {
694+
min: {
695+
height: minimum.height,
696+
width: minimum.width
697+
},
698+
max: {
699+
height: maximum.height,
700+
width: maximum.width
701+
}
702+
}
703+
};
704+
705+
this.interactObj.resizable(opts);
706+
if (!this.resizeEventSet) {
707+
this.resizeEventSet = true;
708+
this.interactObj
709+
.on('resizestart resizemove resizeend', function (event) {
710+
self.handleResize(event);
711+
});
712+
}
713+
} else {
714+
this.interactObj.resizable({
715+
enabled: false
716+
});
717+
}
700718
}
701719
},
702720
}

0 commit comments

Comments
 (0)