Skip to content

Commit 5c1a039

Browse files
authored
Merge pull request jbaysolutions#337 from pmorch/emit-resized-for-more-changes
Emit @Resized whenever pixel width/height changes
2 parents 369b61e + 8886f3a commit 5c1a039

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/components/GridItem.vue

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,17 @@
325325
},
326326
rowHeight: function () {
327327
this.createStyle();
328+
this.emitResized();
328329
},
329330
cols: function () {
330331
this.tryMakeResizable();
331332
this.createStyle();
333+
this.emitResized();
332334
},
333335
containerWidth: function () {
334336
this.tryMakeResizable();
335337
this.createStyle();
338+
this.emitResized();
336339
},
337340
x: function (newVal) {
338341
this.innerX = newVal;
@@ -345,10 +348,12 @@
345348
h: function (newVal) {
346349
this.innerH = newVal
347350
this.createStyle();
351+
this.emitResized();
348352
},
349353
w: function (newVal) {
350354
this.innerW = newVal;
351355
this.createStyle();
356+
this.emitResized();
352357
},
353358
renderRtl: function () {
354359
// console.log("### renderRtl");
@@ -431,7 +436,19 @@
431436
}
432437
}
433438
this.style = style;
434-
439+
},
440+
emitResized() {
441+
// this.style has width and height with trailing 'px'. The
442+
// resized event is without them
443+
let styleProps = {};
444+
for (let prop of ['width', 'height']) {
445+
let val = this.style[prop];
446+
let matches = val.match(/^(\d+)px$/);
447+
if (! matches)
448+
return;
449+
styleProps[prop] = matches[1];
450+
}
451+
this.$emit("resized", this.i, this.h, this.w, styleProps.height, styleProps.width);
435452
},
436453
handleResize: function (event) {
437454
if (this.static) return;

0 commit comments

Comments
 (0)