@glodon-aiot/dataset-annotation 3.10.0-alpha.16 → 3.10.0-alpha.18

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.
@@ -1,45 +1,54 @@
1
- function I(e, u) {
2
- y(e);
3
- let h = -1, s = -1, n = 0, p = 0;
4
- e.on("mouse:down", (g) => {
5
- h = -1, s = -1, n = 0, p = 0;
6
- const i = e.getZoom();
7
- s = g.e.offsetX / i, h = g.e.offsetY / i;
8
- }), e.on("mouse:up", (g) => {
9
- if (s === -1 && h === -1)
1
+ function Y(e, n) {
2
+ T(e);
3
+ let h = -1, s = -1, p = 0, m = 0, w = !1;
4
+ e.on("mouse:down:before", (d) => {
5
+ const f = d.target, u = e.getActiveObject();
6
+ if (f && f !== e.backgroundImage && u === f) {
7
+ e.skipTargetFind = !1;
10
8
  return;
11
- const i = e.getZoom(), m = g.e.offsetX > e.getWidth() ? e.getWidth() / i : g.e.offsetX / i, w = g.e.offsetY > e.getHeight() ? e.getHeight() / i : g.e.offsetY / i;
12
- if (n = Math.abs(m - s), p = Math.abs(w - h), n === 0 || p === 0)
9
+ }
10
+ u && (e.discardActiveObject(), e.renderAll()), e.skipTargetFind = !0;
11
+ }), e.on("mouse:down", (d) => {
12
+ if (!e.skipTargetFind)
13
13
  return;
14
- const T = e.viewportTransform ? e.viewportTransform[4] / i : 0, X = e.viewportTransform ? e.viewportTransform[5] / i : 0;
15
- let f = h > w ? w : h, r = s > m ? m : s, l = n, d = p;
16
- f = f - X, r = r - T;
17
- const Y = () => {
18
- var o, b;
14
+ w = !0, h = -1, s = -1, p = 0, m = 0;
15
+ const f = e.getZoom();
16
+ s = d.e.offsetX / f, h = d.e.offsetY / f;
17
+ }), e.on("mouse:up", (d) => {
18
+ if (e.skipTargetFind = !1, !w || (w = !1, s === -1 && h === -1))
19
+ return;
20
+ const f = e.getZoom(), u = d.e.offsetX > e.getWidth() ? e.getWidth() / f : d.e.offsetX / f, b = d.e.offsetY > e.getHeight() ? e.getHeight() / f : d.e.offsetY / f;
21
+ if (p = Math.abs(u - s), m = Math.abs(b - h), p === 0 || m === 0)
22
+ return;
23
+ const y = e.viewportTransform ? e.viewportTransform[4] / f : 0, F = e.viewportTransform ? e.viewportTransform[5] / f : 0;
24
+ let r = h > b ? b : h, i = s > u ? u : s, l = p, g = m;
25
+ r = r - F, i = i - y;
26
+ const I = () => {
27
+ var o, k;
19
28
  const t = e.backgroundImage;
20
- t && typeof t != "string" && ((o = t.aCoords) != null && o.tl.x, (b = t.aCoords) != null && b.tl.y), t && typeof t != "string" && t.top !== void 0 && t.height !== void 0 && t.left !== void 0 && t.width !== void 0 && (f < t.top && (d = d - (t.top - f), f = t.top), f + d > t.top + t.height && (d = t.top + t.height - f + d - d, f = t.height + t.top - d), r < t.left && (l = l - (t.left - r), r = t.left), r + l > t.left + t.width && (l = t.left + t.width - r + l - l, r = t.width + t.left - l));
21
- }, k = (t) => {
29
+ t && typeof t != "string" && ((o = t.aCoords) != null && o.tl.x, (k = t.aCoords) != null && k.tl.y), t && typeof t != "string" && t.top !== void 0 && t.height !== void 0 && t.left !== void 0 && t.width !== void 0 && (r < t.top && (g = g - (t.top - r), r = t.top), r + g > t.top + t.height && (g = t.top + t.height - r + g - g, r = t.height + t.top - g), i < t.left && (l = l - (t.left - i), i = t.left), i + l > t.left + t.width && (l = t.left + t.width - i + l - l, i = t.width + t.left - l));
30
+ }, X = (t) => {
22
31
  const o = e.backgroundImage;
23
32
  return !(o && typeof o != "string" && o.top !== void 0 && o.height !== void 0 && o.left !== void 0 && o.width !== void 0 && (t[0] < o.left || t[1] < o.top || t[0] > o.left + o.width || t[1] > o.top + o.height));
24
33
  };
25
- Y();
26
- const c = [[r, f], [r + l, f], [r + l, f + d], [r, f + d]];
27
- u && c.every((t) => k(t)) && u({
34
+ I();
35
+ const c = [[i, r], [i + l, r], [i + l, r + g], [i, r + g]];
36
+ n && c.every((t) => X(t)) && n({
28
37
  id: "",
29
38
  color: "#cccccc",
30
39
  label: "未知",
31
40
  box: c
32
- }), e.skipTargetFind = !1, y(e);
41
+ }), T(e);
33
42
  });
34
43
  }
35
- const y = (e) => {
36
- e.off("mouse:down"), e.off("mouse:up");
44
+ const T = (e) => {
45
+ e.off("mouse:down"), e.off("mouse:down:before"), e.off("mouse:up"), e.skipTargetFind = !1;
37
46
  };
38
- function x(e, u, h) {
47
+ function j(e, n, h) {
39
48
  if (!h)
40
- return I(e, u), e;
49
+ return Y(e, n), e;
41
50
  }
42
51
  export {
43
- x as drawable,
44
- y as stopDraw
52
+ j as drawable,
53
+ T as stopDraw
45
54
  };