Skip to content

Commit eff01db

Browse files
committed
renamed 'resized' event emitted when the container changes size (browser window or other), introduced in jbaysolutions#337, fixes jbaysolutions#358
1 parent 6235b41 commit eff01db

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

examples/02-events.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ <h1>Vue Grid Layout Example 2 - Move and resize events</h1>
6060
@resize="resizeEvent"
6161
@move="moveEvent"
6262
@resized="resizedEvent"
63+
@container-resized="containerResizedEvent"
6364
@moved="movedEvent"
6465
>
6566
<span class="text">{{item.i}}</span>

examples/02-events.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ new Vue({
5858
console.log(msg);
5959

6060
},
61+
containerResized: function(i, newH, newW, newHPx, newWPx){
62+
console.log("### CONTAINER RESIZED i=" + i + ", H=" + newH + ", W=" + newW + ", H(px)=" + newHPx + ", W(px)=" + newWPx);
63+
},
6164
/**
6265
*
6366
* @param i the item id/index

src/App.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
@resize="resize"
6262
@move="move"
6363
@resized="resized"
64+
@container-resized="containerResized"
6465
@moved="moved"
6566
>
6667
<!--<custom-drag-element :text="item.i"></custom-drag-element>-->
@@ -191,6 +192,9 @@
191192
resized: function(i, newH, newW, newHPx, newWPx){
192193
console.log("### RESIZED i=" + i + ", H=" + newH + ", W=" + newW + ", H(px)=" + newHPx + ", W(px)=" + newWPx);
193194
},
195+
containerResized: function(i, newH, newW, newHPx, newWPx){
196+
console.log("### CONTAINER RESIZED i=" + i + ", H=" + newH + ", W=" + newW + ", H(px)=" + newHPx + ", W(px)=" + newWPx);
197+
},
194198
/**
195199
* Add change direction button
196200
*/

src/components/GridItem.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -331,17 +331,17 @@
331331
},
332332
rowHeight: function () {
333333
this.createStyle();
334-
this.emitResized();
334+
this.emitContainerResized();
335335
},
336336
cols: function () {
337337
this.tryMakeResizable();
338338
this.createStyle();
339-
this.emitResized();
339+
this.emitContainerResized();
340340
},
341341
containerWidth: function () {
342342
this.tryMakeResizable();
343343
this.createStyle();
344-
this.emitResized();
344+
this.emitContainerResized();
345345
},
346346
x: function (newVal) {
347347
this.innerX = newVal;
@@ -354,12 +354,12 @@
354354
h: function (newVal) {
355355
this.innerH = newVal
356356
this.createStyle();
357-
this.emitResized();
357+
// this.emitContainerResized();
358358
},
359359
w: function (newVal) {
360360
this.innerW = newVal;
361361
this.createStyle();
362-
this.emitResized();
362+
// this.emitContainerResized();
363363
},
364364
renderRtl: function () {
365365
// console.log("### renderRtl");
@@ -458,7 +458,7 @@
458458
}
459459
this.style = style;
460460
},
461-
emitResized() {
461+
emitContainerResized() {
462462
// this.style has width and height with trailing 'px'. The
463463
// resized event is without them
464464
let styleProps = {};
@@ -469,7 +469,7 @@
469469
return;
470470
styleProps[prop] = matches[1];
471471
}
472-
this.$emit("resized", this.i, this.h, this.w, styleProps.height, styleProps.width);
472+
this.$emit("container-resized", this.i, this.h, this.w, styleProps.height, styleProps.width);
473473
},
474474
handleResize: function (event) {
475475
if (this.static) return;

0 commit comments

Comments
 (0)