|
@@ -19,6 +19,7 @@
|
|
:socket="socket"
|
|
:socket="socket"
|
|
:immutable="false"
|
|
:immutable="false"
|
|
:box-url="mediaUrl + '/' + result.id"
|
|
:box-url="mediaUrl + '/' + result.id"
|
|
|
|
+ @move="move"
|
|
@resize="resize"/>
|
|
@resize="resize"/>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
@@ -114,17 +115,26 @@ export default {
|
|
return (this.get(event).clientY - bcr.top) / bcr.height;
|
|
return (this.get(event).clientY - bcr.top) / bcr.height;
|
|
},
|
|
},
|
|
buildRectangle: function (x1, y1, x2, y2) {
|
|
buildRectangle: function (x1, y1, x2, y2) {
|
|
- const lx = this.fixed && 'lx' in this.fixed ? this.fixed.lx : Math.max(Math.min(x1, x2), 0);
|
|
|
|
- const hx = this.fixed && 'hx' in this.fixed ? this.fixed.hx : Math.min(Math.max(x1, x2), 1);
|
|
|
|
- const ly = this.fixed && 'ly' in this.fixed ? this.fixed.ly : Math.max(Math.min(y1, y2), 0);
|
|
|
|
- const hy = this.fixed && 'hy' in this.fixed ? this.fixed.hy : Math.min(Math.max(y1, y2), 1);
|
|
|
|
|
|
+ let lx, hx, ly, hy;
|
|
|
|
+
|
|
|
|
+ if (this.fixed && 'offsetX' in this.fixed && 'offsetY' in this.fixed) {
|
|
|
|
+ lx = Math.max(x2 + this.fixed.offsetX, 0);
|
|
|
|
+ hx = Math.min(x2 + this.fixed.offsetX + this.fixed.w, 1);
|
|
|
|
+ ly = Math.max(y2 + this.fixed.offsetY, 0);
|
|
|
|
+ hy = Math.min(y2 + this.fixed.offsetY + this.fixed.h, 1);
|
|
|
|
+ } else {
|
|
|
|
+ lx = this.fixed && 'lx' in this.fixed ? this.fixed.lx : Math.max(Math.min(x1, x2), 0);
|
|
|
|
+ hx = this.fixed && 'hx' in this.fixed ? this.fixed.hx : Math.min(Math.max(x1, x2), 1);
|
|
|
|
+ ly = this.fixed && 'ly' in this.fixed ? this.fixed.ly : Math.max(Math.min(y1, y2), 0);
|
|
|
|
+ hy = this.fixed && 'hy' in this.fixed ? this.fixed.hy : Math.min(Math.max(y1, y2), 1);
|
|
|
|
+ }
|
|
|
|
|
|
return {
|
|
return {
|
|
x: lx,
|
|
x: lx,
|
|
y: ly,
|
|
y: ly,
|
|
w: hx - lx,
|
|
w: hx - lx,
|
|
h: hy - ly
|
|
h: hy - ly
|
|
- }
|
|
|
|
|
|
+ };
|
|
},
|
|
},
|
|
press: function (event) {
|
|
press: function (event) {
|
|
this.start = {
|
|
this.start = {
|
|
@@ -153,6 +163,15 @@ export default {
|
|
this.callback = false;
|
|
this.callback = false;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ move: function (event, position, callback) {
|
|
|
|
+ this.callback = callback;
|
|
|
|
+
|
|
|
|
+ const x = this.getX(event);
|
|
|
|
+ const y = this.getY(event);
|
|
|
|
+
|
|
|
|
+ this.start = {x: position.x, y: position.y};
|
|
|
|
+ this.fixed = {w: position.w, h: position.h, offsetX: position.x - x, offsetY: position.y - y};
|
|
|
|
+ },
|
|
resize: function (position, mode, callback) {
|
|
resize: function (position, mode, callback) {
|
|
this.callback = callback;
|
|
this.callback = callback;
|
|
switch (mode) {
|
|
switch (mode) {
|