@annotorious/annotorious 3.4.0 → 3.4.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@annotorious/annotorious",
3
- "version": "3.4.0",
3
+ "version": "3.4.1",
4
4
  "description": "Add image annotation functionality to any web page with a few lines of JavaScript",
5
5
  "author": "Rainer Simon",
6
6
  "license": "BSD-3-Clause",
@@ -49,7 +49,7 @@
49
49
  "vitest": "^3.1.4"
50
50
  },
51
51
  "dependencies": {
52
- "@annotorious/core": "3.4.0",
52
+ "@annotorious/core": "3.4.1",
53
53
  "rbush": "^4.0.1",
54
54
  "svg-pathdata": "^7.2.0",
55
55
  "uuid": "^11.1.0"
@@ -11,7 +11,7 @@
11
11
  top: 0;
12
12
  touch-action: none;
13
13
  width: 100%;
14
-
14
+ -webkit-tap-highlight-color: transparent;
15
15
  -webkit-user-select: none;
16
16
  -moz-user-select: none;
17
17
  -ms-user-select: none;
@@ -34,6 +34,7 @@
34
34
  fill: transparent;
35
35
  shape-rendering: geometricPrecision;
36
36
  vector-effect: non-scaling-stroke;
37
+ -webkit-tap-highlight-color: transparent;
37
38
  }
38
39
 
39
40
  .a9s-edge-handle {
@@ -21,10 +21,30 @@
21
21
  </script>
22
22
 
23
23
  {#if isTouch}
24
- <circle
25
- cx={x}
26
- cy={y}
27
- r={2 * handleRadius} />
24
+ <g class="a9s-touch-handle">
25
+ <circle
26
+ cx={x}
27
+ cy={y}
28
+ r={handleRadius * 10}
29
+ class="a9s-touch-halo"
30
+ class:touched={touched} />
31
+
32
+ <circle
33
+ cx={x}
34
+ cy={y}
35
+ r={handleRadius + 10 / scale}
36
+ class="a9s-handle-buffer"
37
+ on:pointerdown
38
+ on:pointerup
39
+ on:pointerdown={onPointerDown}
40
+ on:pointerup={onPointerUp} />
41
+
42
+ <circle
43
+ class="a9s-handle-dot"
44
+ cx={x}
45
+ cy={y}
46
+ r={handleRadius + 2 / scale} />
47
+ </g>
28
48
  {:else}
29
49
  <g class={`a9s-handle ${$$props.class || ''}`.trim()}>
30
50
  <circle
@@ -44,7 +64,7 @@
44
64
  class="a9s-handle-selected"
45
65
  cx={x}
46
66
  cy={y}
47
- r={handleRadius + (6 / scale)} />
67
+ r={handleRadius + (8 / scale)} />
48
68
  {/if}
49
69
 
50
70
  <circle
@@ -56,6 +76,17 @@
56
76
  {/if}
57
77
 
58
78
  <style>
79
+ .a9s-touch-halo {
80
+ fill: transparent;
81
+ pointer-events: none;
82
+ stroke-width: 0;
83
+ transition: fill 150ms;
84
+ }
85
+
86
+ .a9s-touch-halo.touched {
87
+ fill: rgba(255, 255, 255, 0.4);
88
+ }
89
+
59
90
  .a9s-handle-buffer {
60
91
  fill: transparent;
61
92
  }
@@ -2,7 +2,7 @@
2
2
  import { createEventDispatcher, onMount, tick } from 'svelte';
3
3
  import { boundsFromPoints } from '../../../model';
4
4
  import type { Polygon, PolygonGeometry, Shape } from '../../../model';
5
- import { getMaskDimensions } from '../../utils';
5
+ import { getMaskDimensions, isTouch } from '../../utils';
6
6
  import type { Transform } from '../../Transform';
7
7
  import Editor from '../Editor.svelte';
8
8
  import Handle from '../Handle.svelte';
@@ -38,7 +38,8 @@
38
38
 
39
39
  $: geom = shape.geometry;
40
40
 
41
- $: midpoints = geom.points.map((thisCorner, idx) => {
41
+ // No support yet for adding or removing points in mobile!
42
+ $: midpoints = isTouch ? [] : geom.points.map((thisCorner, idx) => {
42
43
  const nextCorner = idx === geom.points.length - 1 ? geom.points[0] : geom.points[idx + 1];
43
44
 
44
45
  const x = (thisCorner[0] + nextCorner[0]) / 2;
@@ -122,7 +123,7 @@
122
123
 
123
124
  /** Selection handling logic **/
124
125
  const onHandlePointerUp = (idx: number) => (evt: PointerEvent) => {
125
- if (!lastHandleClick) return;
126
+ if (!lastHandleClick || isTouch) return;
126
127
 
127
128
  // Drag, not click
128
129
  if (performance.now() - lastHandleClick > CLICK_THRESHOLD) return;
@@ -225,6 +226,8 @@
225
226
  }
226
227
 
227
228
  onMount(() => {
229
+ if (isTouch) return;
230
+
228
231
  const onKeydown = (evt: KeyboardEvent) => {
229
232
  if (evt.key === 'Delete' || evt.key === 'Backspace') {
230
233
  evt.preventDefault();