Skip to content

Commit 586a1c6

Browse files
committed
move and resize events optimization
1 parent 3edc562 commit 586a1c6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/App.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@
117117
this.layout.push(item);
118118
},
119119
move: function(i, newX, newY){
120-
console.log(i, newX, newY)
120+
console.log("MOVE i=" + i + ", X=" + newX + ", Y=" + newY);
121121
},
122122
resize: function(i, newH, newW){
123-
console.log(i, newH, newW)
123+
console.log("RESIZE i=" + i + ", H=" + newH + ", W=" + newW);
124124
},
125125
/**
126126
* Add change direction button

src/GridItem.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,10 @@
374374
this.lastW = x;
375375
this.lastH = y;
376376
377+
if (this.w !== pos.w || this.h !== pos.h) {
378+
this.$emit("resize", this.i, pos.h, pos.w);
379+
}
377380
eventBus.$emit("resizeEvent", event.type, this.i, this.x, this.y, pos.h, pos.w);
378-
this.$emit("resize", this.i, pos.h, pos.w);
379381
},
380382
handleDrag(event) {
381383
if (this.isResizing) return;
@@ -444,8 +446,10 @@
444446
this.lastX = x;
445447
this.lastY = y;
446448
449+
if (this.x !== pos.x || this.y !== pos.y) {
450+
this.$emit("move", this.i, pos.x, pos.y);
451+
}
447452
eventBus.$emit("dragEvent", event.type, this.i, pos.x, pos.y, this.h, this.w);
448-
this.$emit("move", this.i, pos.x, pos.y);
449453
},
450454
calcPosition: function(x, y, w, h) {
451455
const colWidth = this.calcColWidth();

0 commit comments

Comments
 (0)