|
@@ -13,11 +13,13 @@
|
|
|
<annotation-box v-for="(result, index) in predictions"
|
|
|
type="server"
|
|
|
:key="index"
|
|
|
+ :id="result.id"
|
|
|
:image="image"
|
|
|
:position="result"
|
|
|
:socket="socket"
|
|
|
:immutable="false"
|
|
|
- :box-url="mediaUrl + '/' + result.id"/>
|
|
|
+ :box-url="mediaUrl + '/' + result.id"
|
|
|
+ @resize="resize"/>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -55,7 +57,9 @@ export default {
|
|
|
height: 0
|
|
|
},
|
|
|
start: false,
|
|
|
- current: false
|
|
|
+ fixed: false,
|
|
|
+ current: false,
|
|
|
+ callback: false
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -110,10 +114,10 @@ export default {
|
|
|
return (this.get(event).clientY - bcr.top) / bcr.height;
|
|
|
},
|
|
|
buildRectangle: function (x1, y1, x2, y2) {
|
|
|
- const lx = Math.max(Math.min(x1, x2), 0);
|
|
|
- const hx = Math.min(Math.max(x1, x2), 1);
|
|
|
- const ly = Math.max(Math.min(y1, y2), 0);
|
|
|
- const hy = Math.min(Math.max(y1, y2), 1);
|
|
|
+ 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);
|
|
|
|
|
|
return {
|
|
|
x: lx,
|
|
@@ -138,9 +142,52 @@ export default {
|
|
|
},
|
|
|
release: function () {
|
|
|
if (this.start) {
|
|
|
- this.socket.post(this.mediaUrl, this.current);
|
|
|
+ if (this.callback)
|
|
|
+ this.callback(this.current);
|
|
|
+ else
|
|
|
+ this.socket.post(this.mediaUrl, this.current);
|
|
|
+
|
|
|
this.start = false;
|
|
|
+ this.fixed = false;
|
|
|
this.current = false;
|
|
|
+ this.callback = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ resize: function (position, mode, callback) {
|
|
|
+ this.callback = callback;
|
|
|
+ switch (mode) {
|
|
|
+ case 'nw':
|
|
|
+ this.start = {x: position.x + position.w, y: position.y + position.h};
|
|
|
+ this.fixed = false;
|
|
|
+ break;
|
|
|
+ case 'ne':
|
|
|
+ this.start = {x: position.x, y: position.y + position.h};
|
|
|
+ this.fixed = false;
|
|
|
+ break;
|
|
|
+ case 'sw':
|
|
|
+ this.start = {x: position.x + position.w, y: position.y};
|
|
|
+ this.fixed = false;
|
|
|
+ break;
|
|
|
+ case 'se':
|
|
|
+ this.start = {x: position.x, y: position.y};
|
|
|
+ this.fixed = false;
|
|
|
+ break;
|
|
|
+ case 'nn':
|
|
|
+ this.start = {x: position.x, y: position.y + position.h};
|
|
|
+ this.fixed = {lx: position.x, hx: position.x + position.w};
|
|
|
+ break;
|
|
|
+ case 'ww':
|
|
|
+ this.start = {x: position.x + position.w, y: position.y};
|
|
|
+ this.fixed = {ly: position.y, hy: position.y + position.h};
|
|
|
+ break;
|
|
|
+ case 'ee':
|
|
|
+ this.start = {x: position.x, y: position.y};
|
|
|
+ this.fixed = {ly: position.y, hy: position.y + position.h};
|
|
|
+ break;
|
|
|
+ case 'ss':
|
|
|
+ this.start = {x: position.x, y: position.y};
|
|
|
+ this.fixed = {lx: position.x, hx: position.x + position.w};
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|