@operato/image-marker 8.0.0-alpha.22 → 8.0.0-alpha.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/src/base-image-marker.d.ts +3 -0
- package/dist/src/base-image-marker.js +20 -0
- package/dist/src/base-image-marker.js.map +1 -1
- package/dist/src/ox-image-marker-mode.d.ts +3 -2
- package/dist/src/ox-image-marker-mode.js +23 -13
- package/dist/src/ox-image-marker-mode.js.map +1 -1
- package/dist/src/ox-image-marker-view.js +1 -0
- package/dist/src/ox-image-marker-view.js.map +1 -1
- package/dist/src/ox-image-marker.d.ts +11 -8
- package/dist/src/ox-image-marker.js +126 -81
- package/dist/src/ox-image-marker.js.map +1 -1
- package/dist/src/types.d.ts +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/base-image-marker.ts +30 -0
- package/src/ox-image-marker-mode.ts +28 -15
- package/src/ox-image-marker-view.ts +1 -0
- package/src/ox-image-marker.ts +140 -81
- package/src/types.ts +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import './ox-image-marker-mode';
|
|
3
3
|
import { html, css, svg, nothing } from 'lit';
|
|
4
|
-
import { state, customElement } from 'lit/decorators.js';
|
|
4
|
+
import { query, state, customElement } from 'lit/decorators.js';
|
|
5
5
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
6
6
|
import { keyed } from 'lit/directives/keyed.js';
|
|
7
7
|
import { BaseImageMarker } from './base-image-marker';
|
|
8
8
|
let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
9
9
|
constructor() {
|
|
10
10
|
super(...arguments);
|
|
11
|
-
this.currentMode = '
|
|
11
|
+
this.currentMode = 'edit';
|
|
12
12
|
this.selectedShape = null;
|
|
13
13
|
this.drawing = false;
|
|
14
14
|
this.startX = 0;
|
|
@@ -16,26 +16,28 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
16
16
|
this.offsetX = 0;
|
|
17
17
|
this.offsetY = 0;
|
|
18
18
|
this.onSvgTouchStart = (event) => {
|
|
19
|
+
event.preventDefault();
|
|
20
|
+
if (this.isDoubleTouch(event)) {
|
|
21
|
+
this.resetZoom();
|
|
22
|
+
}
|
|
19
23
|
if (event.touches.length === 1) {
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
return { ...s, selected: false };
|
|
23
|
-
});
|
|
24
|
-
if (this.currentMode === 'move') {
|
|
25
|
-
this.startPanning(event);
|
|
26
|
-
}
|
|
27
|
-
else if (this.currentMode === 'draw') {
|
|
24
|
+
this.setSelectedShape(null);
|
|
25
|
+
if (this.currentMode === 'shape') {
|
|
28
26
|
this.startDrawing(event);
|
|
29
27
|
}
|
|
28
|
+
else {
|
|
29
|
+
this.startPanning(event);
|
|
30
|
+
}
|
|
30
31
|
}
|
|
31
32
|
else if (event.touches.length === 2) {
|
|
32
33
|
this.startPinchZooming(event);
|
|
33
34
|
}
|
|
34
35
|
};
|
|
35
|
-
this.
|
|
36
|
+
this.onMouseMoveForDrawing = (event) => {
|
|
36
37
|
if (!this.drawing) {
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
40
|
+
event.preventDefault();
|
|
39
41
|
const { x, y } = this.getSvgPoint(event);
|
|
40
42
|
const minDistance = 5;
|
|
41
43
|
const distance = Math.sqrt(Math.pow(x - this.startX, 2) + Math.pow(y - this.startY, 2));
|
|
@@ -95,8 +97,8 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
95
97
|
default:
|
|
96
98
|
return;
|
|
97
99
|
}
|
|
98
|
-
this.selectedShape = newShape;
|
|
99
100
|
this.shapes = [...this.shapes, newShape];
|
|
101
|
+
this.setSelectedShape(newShape);
|
|
100
102
|
}
|
|
101
103
|
if (this.selectedShape) {
|
|
102
104
|
switch (this.selectedShape.type) {
|
|
@@ -127,26 +129,26 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
127
129
|
this.requestUpdate();
|
|
128
130
|
}
|
|
129
131
|
};
|
|
130
|
-
this.
|
|
132
|
+
this.onMouseUpForDrawing = (event) => {
|
|
133
|
+
event.preventDefault();
|
|
131
134
|
this.drawing = false;
|
|
132
135
|
const svg = this.svg;
|
|
133
136
|
if ('touches' in event) {
|
|
134
|
-
svg.removeEventListener('touchmove', this.
|
|
135
|
-
svg.removeEventListener('touchend', this.
|
|
137
|
+
svg.removeEventListener('touchmove', this.onMouseMoveForDrawing);
|
|
138
|
+
svg.removeEventListener('touchend', this.onMouseUpForDrawing);
|
|
136
139
|
}
|
|
137
140
|
else {
|
|
138
|
-
svg.removeEventListener('mousemove', this.
|
|
139
|
-
svg.removeEventListener('mouseup', this.
|
|
140
|
-
}
|
|
141
|
-
if (this.selectedShape) {
|
|
142
|
-
this.selectedShape.selected = true;
|
|
141
|
+
svg.removeEventListener('mousemove', this.onMouseMoveForDrawing);
|
|
142
|
+
svg.removeEventListener('mouseup', this.onMouseUpForDrawing);
|
|
143
143
|
}
|
|
144
|
+
this.imageMarkerMode.setMode('edit');
|
|
144
145
|
this.requestUpdate();
|
|
145
146
|
};
|
|
146
|
-
this.
|
|
147
|
+
this.onMouseMoveOnShape = (event) => {
|
|
147
148
|
if (!this.selectedShape) {
|
|
148
149
|
return;
|
|
149
150
|
}
|
|
151
|
+
event.preventDefault();
|
|
150
152
|
const { x, y } = this.getSvgPoint(event);
|
|
151
153
|
switch (this.selectedShape.type) {
|
|
152
154
|
case 'text':
|
|
@@ -179,29 +181,25 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
179
181
|
}
|
|
180
182
|
this.requestUpdate();
|
|
181
183
|
};
|
|
182
|
-
this.
|
|
184
|
+
this.onMouseUpOnShape = (event) => {
|
|
185
|
+
event.preventDefault();
|
|
183
186
|
const svg = this.svg;
|
|
184
187
|
if ('touches' in event) {
|
|
185
|
-
svg.removeEventListener('touchmove', this.
|
|
186
|
-
svg.removeEventListener('touchend', this.
|
|
188
|
+
svg.removeEventListener('touchmove', this.onMouseMoveOnShape);
|
|
189
|
+
svg.removeEventListener('touchend', this.onMouseUpOnShape);
|
|
187
190
|
}
|
|
188
191
|
else {
|
|
189
|
-
svg.removeEventListener('mousemove', this.
|
|
190
|
-
svg.removeEventListener('mouseup', this.
|
|
192
|
+
svg.removeEventListener('mousemove', this.onMouseMoveOnShape);
|
|
193
|
+
svg.removeEventListener('mouseup', this.onMouseUpOnShape);
|
|
191
194
|
}
|
|
192
195
|
};
|
|
193
|
-
this.
|
|
196
|
+
this.onResizeHandleMouseMove = (event) => {
|
|
194
197
|
if (!this.selectedShape) {
|
|
195
198
|
return;
|
|
196
199
|
}
|
|
200
|
+
event.preventDefault();
|
|
197
201
|
const { x, y } = this.getSvgPoint(event);
|
|
198
202
|
switch (this.selectedShape.type) {
|
|
199
|
-
// case 'text':
|
|
200
|
-
// this.selectedShape.width = Math.abs(x - this.selectedShape.x!)
|
|
201
|
-
// this.selectedShape.height = Math.abs(y - this.selectedShape.y!)
|
|
202
|
-
// if (x < this.selectedShape.x!) this.selectedShape.x = x
|
|
203
|
-
// if (y < this.selectedShape.y!) this.selectedShape.y = y
|
|
204
|
-
// break
|
|
205
203
|
case 'rectangle':
|
|
206
204
|
const startX = this.selectedShape.x;
|
|
207
205
|
const startY = this.selectedShape.y;
|
|
@@ -269,17 +267,17 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
269
267
|
}
|
|
270
268
|
this.requestUpdate();
|
|
271
269
|
};
|
|
272
|
-
this.
|
|
270
|
+
this.onResizeHandleMouseUp = (event) => {
|
|
271
|
+
event.preventDefault();
|
|
273
272
|
const svg = this.svg;
|
|
274
273
|
if ('touches' in event) {
|
|
275
|
-
svg.removeEventListener('touchmove', this.
|
|
276
|
-
svg.removeEventListener('touchend', this.
|
|
274
|
+
svg.removeEventListener('touchmove', this.onResizeHandleMouseMove);
|
|
275
|
+
svg.removeEventListener('touchend', this.onResizeHandleMouseUp);
|
|
277
276
|
}
|
|
278
277
|
else {
|
|
279
|
-
svg.removeEventListener('mousemove', this.
|
|
280
|
-
svg.removeEventListener('mouseup', this.
|
|
278
|
+
svg.removeEventListener('mousemove', this.onResizeHandleMouseMove);
|
|
279
|
+
svg.removeEventListener('mouseup', this.onResizeHandleMouseUp);
|
|
281
280
|
}
|
|
282
|
-
this.selectedShape = null;
|
|
283
281
|
};
|
|
284
282
|
this.onFocus = () => {
|
|
285
283
|
this.addEventListener('keydown', this.handleKeyDown);
|
|
@@ -310,11 +308,11 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
310
308
|
}
|
|
311
309
|
|
|
312
310
|
svg {
|
|
313
|
-
cursor:
|
|
311
|
+
cursor: default;
|
|
314
312
|
}
|
|
315
313
|
|
|
316
|
-
svg
|
|
317
|
-
cursor:
|
|
314
|
+
svg[drawing] {
|
|
315
|
+
cursor: crosshair;
|
|
318
316
|
}
|
|
319
317
|
|
|
320
318
|
.resize-handle {
|
|
@@ -342,6 +340,7 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
342
340
|
@wheel=${this.onSvgWheel}
|
|
343
341
|
@dblclick=${this.onSvgDoubleClick}
|
|
344
342
|
viewBox=${this.viewBox}
|
|
343
|
+
?drawing=${this.currentMode == 'shape'}
|
|
345
344
|
>
|
|
346
345
|
<image href=${this.imageUrl} @load=${this.onImageLoad}></image>
|
|
347
346
|
${this.shapes.map(shape => keyed(shape.id, this.renderShape(shape)))}
|
|
@@ -355,6 +354,7 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
355
354
|
const { mode, shapeType } = e.detail;
|
|
356
355
|
this.setMode(mode, shapeType);
|
|
357
356
|
}}
|
|
357
|
+
@tap-fit-size=${() => this.resetZoom()}
|
|
358
358
|
@tap-delete=${() => this.deleteSelectedShape()}
|
|
359
359
|
@tap-save=${() => {
|
|
360
360
|
this.dispatchEvent(new CustomEvent('shapes-changed', {
|
|
@@ -367,16 +367,14 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
367
367
|
`;
|
|
368
368
|
}
|
|
369
369
|
onSvgMouseDown(event) {
|
|
370
|
-
|
|
371
|
-
this.
|
|
372
|
-
|
|
373
|
-
});
|
|
374
|
-
if (this.currentMode === 'move') {
|
|
375
|
-
this.startPanning(event);
|
|
376
|
-
}
|
|
377
|
-
else if (this.currentMode === 'draw') {
|
|
370
|
+
event.preventDefault();
|
|
371
|
+
this.setSelectedShape(null);
|
|
372
|
+
if (this.currentMode === 'shape') {
|
|
378
373
|
this.startDrawing(event);
|
|
379
374
|
}
|
|
375
|
+
else {
|
|
376
|
+
this.startPanning(event);
|
|
377
|
+
}
|
|
380
378
|
}
|
|
381
379
|
startDrawing(event) {
|
|
382
380
|
const { x, y } = this.getSvgPoint(event);
|
|
@@ -396,18 +394,32 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
396
394
|
this.drawing = true;
|
|
397
395
|
}
|
|
398
396
|
if ('touches' in event) {
|
|
399
|
-
this.svg.addEventListener('touchmove', this.
|
|
400
|
-
this.svg.addEventListener('touchend', this.
|
|
397
|
+
this.svg.addEventListener('touchmove', this.onMouseMoveForDrawing);
|
|
398
|
+
this.svg.addEventListener('touchend', this.onMouseUpForDrawing);
|
|
401
399
|
}
|
|
402
400
|
else {
|
|
403
|
-
this.svg.addEventListener('mousemove', this.
|
|
404
|
-
this.svg.addEventListener('mouseup', this.
|
|
401
|
+
this.svg.addEventListener('mousemove', this.onMouseMoveForDrawing);
|
|
402
|
+
this.svg.addEventListener('mouseup', this.onMouseUpForDrawing);
|
|
405
403
|
}
|
|
406
404
|
}
|
|
407
405
|
setMode(mode, shapeType) {
|
|
406
|
+
if (mode == 'view') {
|
|
407
|
+
this.setSelectedShape(null);
|
|
408
|
+
}
|
|
408
409
|
this.currentMode = mode;
|
|
409
410
|
this.currentShapeType = shapeType;
|
|
410
411
|
}
|
|
412
|
+
setSelectedShape(shape) {
|
|
413
|
+
this.selectedShape = shape;
|
|
414
|
+
if (!shape) {
|
|
415
|
+
this.shapes = this.shapes.map(s => {
|
|
416
|
+
return { ...s, selected: false };
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
this.selectedShape.selected = true;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
411
423
|
getSvgPoint(event) {
|
|
412
424
|
const { x, y } = this.getPointFromEvent(event);
|
|
413
425
|
const svg = this.svg;
|
|
@@ -432,8 +444,8 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
432
444
|
y="${shape.y}"
|
|
433
445
|
fill="${commonAttrs.stroke}"
|
|
434
446
|
style="cursor: ${commonAttrs.cursor}; font-size: 16px;"
|
|
435
|
-
@mousedown="${(e) => this.
|
|
436
|
-
@touchstart="${(e) => this.
|
|
447
|
+
@mousedown="${(e) => this.onMouseDownOnShape(e, shape)}"
|
|
448
|
+
@touchstart="${(e) => this.onMouseDownOnShape(e, shape)}"
|
|
437
449
|
@dblclick="${(e) => this.onTextDoubleClick(e, shape)}"
|
|
438
450
|
>${shape.text}</text>
|
|
439
451
|
`;
|
|
@@ -448,8 +460,8 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
448
460
|
stroke-width="${commonAttrs['stroke-width']}"
|
|
449
461
|
fill="${commonAttrs.fill}"
|
|
450
462
|
style="cursor: ${commonAttrs.cursor}"
|
|
451
|
-
@mousedown="${(e) => this.
|
|
452
|
-
@touchstart="${(e) => this.
|
|
463
|
+
@mousedown="${(e) => this.onMouseDownOnShape(e, shape)}"
|
|
464
|
+
@touchstart="${(e) => this.onMouseDownOnShape(e, shape)}"
|
|
453
465
|
></rect>
|
|
454
466
|
${shape.selected ? this.renderResizeHandles(shape) : ''}
|
|
455
467
|
`;
|
|
@@ -463,8 +475,8 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
463
475
|
stroke-width="${commonAttrs['stroke-width']}"
|
|
464
476
|
fill="${commonAttrs.fill}"
|
|
465
477
|
style="cursor: ${commonAttrs.cursor}"
|
|
466
|
-
@mousedown="${(e) => this.
|
|
467
|
-
@touchstart="${(e) => this.
|
|
478
|
+
@mousedown="${(e) => this.onMouseDownOnShape(e, shape)}"
|
|
479
|
+
@touchstart="${(e) => this.onMouseDownOnShape(e, shape)}"
|
|
468
480
|
></circle>
|
|
469
481
|
${shape.selected ? this.renderResizeHandles(shape) : ''}
|
|
470
482
|
`;
|
|
@@ -476,8 +488,8 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
476
488
|
stroke-width="${commonAttrs['stroke-width']}"
|
|
477
489
|
fill="${commonAttrs.fill}"
|
|
478
490
|
style="cursor: ${commonAttrs.cursor}"
|
|
479
|
-
@mousedown="${(e) => this.
|
|
480
|
-
@touchstart="${(e) => this.
|
|
491
|
+
@mousedown="${(e) => this.onMouseDownOnShape(e, shape)}"
|
|
492
|
+
@touchstart="${(e) => this.onMouseDownOnShape(e, shape)}"
|
|
481
493
|
></polygon>
|
|
482
494
|
${shape.selected ? this.renderResizeHandles(shape) : ''}
|
|
483
495
|
`;
|
|
@@ -491,8 +503,20 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
491
503
|
stroke="${commonAttrs.stroke}"
|
|
492
504
|
stroke-width="${commonAttrs['stroke-width']}"
|
|
493
505
|
style="cursor: ${commonAttrs.cursor}"
|
|
494
|
-
|
|
495
|
-
|
|
506
|
+
></line>
|
|
507
|
+
<line
|
|
508
|
+
x1="${shape.x1}"
|
|
509
|
+
y1="${shape.y1}"
|
|
510
|
+
x2="${shape.x2 ?? shape.x1}"
|
|
511
|
+
y2="${shape.y2 ?? shape.y1}"
|
|
512
|
+
stroke="${commonAttrs.stroke}"
|
|
513
|
+
stroke-width="25"
|
|
514
|
+
stroke-opacity="0"
|
|
515
|
+
pointer-events="stroke"
|
|
516
|
+
@mousedown="${(e) => this.onMouseDownOnShape(e, shape)}"
|
|
517
|
+
@touchstart="${(e) => this.onMouseDownOnShape(e, shape)}"
|
|
518
|
+
@mouseenter="${() => (this.svg.style.cursor = 'pointer')}"
|
|
519
|
+
@mouseleave="${() => (this.svg.style.cursor = 'default')}"
|
|
496
520
|
></line>
|
|
497
521
|
${shape.selected ? this.renderResizeHandles(shape) : ''}
|
|
498
522
|
`;
|
|
@@ -512,8 +536,20 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
512
536
|
stroke-width="${commonAttrs['stroke-width']}"
|
|
513
537
|
marker-end="url(#arrowhead-${shape.id})"
|
|
514
538
|
style="cursor: ${commonAttrs.cursor}"
|
|
515
|
-
|
|
516
|
-
|
|
539
|
+
></line>
|
|
540
|
+
<line
|
|
541
|
+
x1="${shape.x1}"
|
|
542
|
+
y1="${shape.y1}"
|
|
543
|
+
x2="${shape.x2 ?? shape.x1}"
|
|
544
|
+
y2="${shape.y2 ?? shape.y1}"
|
|
545
|
+
stroke="${commonAttrs.stroke}"
|
|
546
|
+
stroke-width="25"
|
|
547
|
+
stroke-opacity="0"
|
|
548
|
+
pointer-events="stroke"
|
|
549
|
+
@mousedown="${(e) => this.onMouseDownOnShape(e, shape)}"
|
|
550
|
+
@touchstart="${(e) => this.onMouseDownOnShape(e, shape)}"
|
|
551
|
+
@mouseenter="${() => (this.svg.style.cursor = 'pointer')}"
|
|
552
|
+
@mouseleave="${() => (this.svg.style.cursor = 'default')}"
|
|
517
553
|
></line>
|
|
518
554
|
${shape.selected ? this.renderResizeHandles(shape) : ''}
|
|
519
555
|
`;
|
|
@@ -521,13 +557,17 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
521
557
|
return nothing;
|
|
522
558
|
}
|
|
523
559
|
}
|
|
524
|
-
|
|
560
|
+
onMouseDownOnShape(event, shape) {
|
|
561
|
+
if (this.currentMode !== 'edit') {
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
525
564
|
event.stopPropagation();
|
|
565
|
+
event.preventDefault();
|
|
526
566
|
this.shapes = this.shapes.map(s => ({
|
|
527
567
|
...s,
|
|
528
568
|
selected: s.id === shape.id
|
|
529
569
|
}));
|
|
530
|
-
this.
|
|
570
|
+
this.setSelectedShape(this.shapes.find(s => s.id == shape.id));
|
|
531
571
|
const { x, y } = this.getSvgPoint(event);
|
|
532
572
|
switch (shape.type) {
|
|
533
573
|
case 'text':
|
|
@@ -550,12 +590,12 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
550
590
|
}
|
|
551
591
|
const svg = this.svg;
|
|
552
592
|
if ('touches' in event) {
|
|
553
|
-
svg.addEventListener('touchmove', this.
|
|
554
|
-
svg.addEventListener('touchend', this.
|
|
593
|
+
svg.addEventListener('touchmove', this.onMouseMoveOnShape);
|
|
594
|
+
svg.addEventListener('touchend', this.onMouseUpOnShape);
|
|
555
595
|
}
|
|
556
596
|
else {
|
|
557
|
-
svg.addEventListener('mousemove', this.
|
|
558
|
-
svg.addEventListener('mouseup', this.
|
|
597
|
+
svg.addEventListener('mousemove', this.onMouseMoveOnShape);
|
|
598
|
+
svg.addEventListener('mouseup', this.onMouseUpOnShape);
|
|
559
599
|
}
|
|
560
600
|
}
|
|
561
601
|
renderResizeHandles(shape) {
|
|
@@ -605,30 +645,32 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
605
645
|
stroke="black"
|
|
606
646
|
class="resize-handle"
|
|
607
647
|
style="cursor: ${handle.cursor};"
|
|
608
|
-
@mousedown="${(e) => this.
|
|
609
|
-
@touchstart="${(e) => this.
|
|
648
|
+
@mousedown="${(e) => this.onResizeHandleMouseDown(e, shape, handle)}"
|
|
649
|
+
@touchstart="${(e) => this.onResizeHandleMouseDown(e, shape, handle)}"
|
|
610
650
|
></rect>
|
|
611
651
|
</g>
|
|
612
652
|
`)}
|
|
613
653
|
`;
|
|
614
654
|
}
|
|
615
|
-
|
|
655
|
+
onResizeHandleMouseDown(event, shape, handle) {
|
|
616
656
|
event.stopPropagation();
|
|
617
|
-
|
|
657
|
+
event.preventDefault();
|
|
658
|
+
this.setSelectedShape(shape);
|
|
618
659
|
this.offsetX = handle.x;
|
|
619
660
|
this.offsetY = handle.y;
|
|
620
661
|
const svg = this.svg;
|
|
621
662
|
if ('touches' in event) {
|
|
622
|
-
svg.addEventListener('touchmove', this.
|
|
623
|
-
svg.addEventListener('touchend', this.
|
|
663
|
+
svg.addEventListener('touchmove', this.onResizeHandleMouseMove);
|
|
664
|
+
svg.addEventListener('touchend', this.onResizeHandleMouseUp);
|
|
624
665
|
}
|
|
625
666
|
else {
|
|
626
|
-
svg.addEventListener('mousemove', this.
|
|
627
|
-
svg.addEventListener('mouseup', this.
|
|
667
|
+
svg.addEventListener('mousemove', this.onResizeHandleMouseMove);
|
|
668
|
+
svg.addEventListener('mouseup', this.onResizeHandleMouseUp);
|
|
628
669
|
}
|
|
629
670
|
}
|
|
630
671
|
onTextDoubleClick(event, shape) {
|
|
631
672
|
event.stopPropagation();
|
|
673
|
+
event.preventDefault();
|
|
632
674
|
const textElement = event.target;
|
|
633
675
|
this.showTextInput(textElement, shape);
|
|
634
676
|
}
|
|
@@ -735,7 +777,7 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
735
777
|
deleteSelectedShape() {
|
|
736
778
|
if (this.selectedShape) {
|
|
737
779
|
this.shapes = this.shapes.filter(s => s.id !== this.selectedShape.id);
|
|
738
|
-
this.
|
|
780
|
+
this.setSelectedShape(null);
|
|
739
781
|
this.requestUpdate();
|
|
740
782
|
}
|
|
741
783
|
}
|
|
@@ -749,6 +791,9 @@ __decorate([
|
|
|
749
791
|
__decorate([
|
|
750
792
|
state()
|
|
751
793
|
], OxImageMarker.prototype, "selectedShape", void 0);
|
|
794
|
+
__decorate([
|
|
795
|
+
query('ox-image-marker-mode')
|
|
796
|
+
], OxImageMarker.prototype, "imageMarkerMode", void 0);
|
|
752
797
|
OxImageMarker = __decorate([
|
|
753
798
|
customElement('ox-image-marker')
|
|
754
799
|
], OxImageMarker);
|