@glodon-aiot/dataset-annotation 3.10.0-alpha.21 → 3.10.0-alpha.22

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,114 +1,114 @@
1
- var J = Math.pow;
2
- import { jsx as l, jsxs as Q } from "react/jsx-runtime";
3
- import { useRef as se, useState as b, useEffect as g } from "react";
4
- import { fabric as R } from "fabric";
5
- import { useKeyPress as P } from "ahooks";
1
+ var Q = Math.pow;
2
+ import { jsx as c, jsxs as $ } from "react/jsx-runtime";
3
+ import { useRef as ae, useState as x, useEffect as d } from "react";
4
+ import { fabric as z } from "fabric";
5
+ import { useKeyPress as O } from "ahooks";
6
6
  import "./style.less.mjs";
7
- import le from "react-dom";
8
- import { Spin as ce, Space as fe, Tooltip as X, Button as Z } from "antd";
9
- import _ from "./RectLabel.mjs";
10
- import { drawable as de } from "./Drawable.mjs";
11
- import { ZoomInOutlined as ue, ZoomOutOutlined as me, DragOutlined as ge } from "@ant-design/icons";
7
+ import ce from "react-dom";
8
+ import { Spin as le, Space as fe, Tooltip as R, Button as X } from "antd";
9
+ import V from "./RectLabel.mjs";
10
+ import { drawable as ue } from "./Drawable.mjs";
11
+ import { ZoomInOutlined as de, ZoomOutOutlined as me, DragOutlined as ge } from "@ant-design/icons";
12
12
  import he from "classnames";
13
13
  import { approxeq as L } from "../../../../utils/index.mjs";
14
- const $ = (r) => {
15
- r.off("mouse:down"), r.off("mouse:up");
16
- }, k = (r) => {
17
- var a, w, f;
18
- let s = [];
19
- (a = r.object) != null && a.aCoords && (s = [r.object.aCoords.tl, r.object.aCoords.tr, r.object.aCoords.br, r.object.aCoords.bl]);
20
- const c = {
14
+ const ee = (s) => {
15
+ s.off("mouse:down"), s.off("mouse:up");
16
+ }, E = (s) => {
17
+ var i, j, f;
18
+ let a = [];
19
+ (i = s.object) != null && i.aCoords && (a = [s.object.aCoords.tl, s.object.aCoords.tr, s.object.aCoords.br, s.object.aCoords.bl]);
20
+ const l = {
21
21
  x: 0,
22
22
  y: 0
23
- }, d = {
23
+ }, m = {
24
24
  width: 0,
25
25
  height: 0
26
26
  };
27
- return r.canvas.backgroundImage && typeof r.canvas.backgroundImage != "string" && (c.x = ((w = r.canvas.backgroundImage.aCoords) == null ? void 0 : w.tl.x) || 0, c.y = ((f = r.canvas.backgroundImage.aCoords) == null ? void 0 : f.tl.y) || 0, d.width = r.canvas.backgroundImage.width || 0, d.height = r.canvas.backgroundImage.height || 0), {
28
- id: r.config.id,
29
- label: r.config.name,
30
- color: r.config.color,
31
- box: (s == null ? void 0 : s.map((u) => [L(u.x - c.x, 0) ? 0 : L(u.x - c.x, d.width) ? d.width : u.x - c.x, L(u.y - c.y, 0) ? 0 : L(u.y - c.y, d.height) ? d.height : u.y - c.y])) || []
27
+ return s.canvas.backgroundImage && typeof s.canvas.backgroundImage != "string" && (l.x = ((j = s.canvas.backgroundImage.aCoords) == null ? void 0 : j.tl.x) || 0, l.y = ((f = s.canvas.backgroundImage.aCoords) == null ? void 0 : f.tl.y) || 0, m.width = s.canvas.backgroundImage.width || 0, m.height = s.canvas.backgroundImage.height || 0), {
28
+ id: s.config.id,
29
+ label: s.config.name,
30
+ color: s.config.color,
31
+ box: (a == null ? void 0 : a.map((h) => [L(h.x - l.x, 0) ? 0 : L(h.x - l.x, m.width) ? m.width : h.x - l.x, L(h.y - l.y, 0) ? 0 : L(h.y - l.y, m.height) ? m.height : h.y - l.y])) || []
32
32
  };
33
- }, Ne = (r) => {
34
- const s = se(null), {
35
- labels: c,
36
- imageUrl: d,
37
- pen: a,
38
- onImageLoad: w,
33
+ }, Le = (s) => {
34
+ const a = ae(null), {
35
+ labels: l,
36
+ imageUrl: m,
37
+ pen: i,
38
+ onImageLoad: j,
39
39
  onChange: f,
40
- isPreLabel: u,
41
- disabled: x,
42
- renderLabelItem: O
43
- } = r, [N, B] = b(!0), [e, T] = b(), [pe, V] = b({}), [y, U] = b(), [H, ee] = b({
40
+ isPreLabel: h,
41
+ disabled: k,
42
+ renderLabelItem: N
43
+ } = s, [S, B] = x(!0), [e, Z] = x(), [pe, te] = x({}), [I, _] = x(), [W, oe] = x({
44
44
  left: 0,
45
45
  top: 0
46
- }), [te, S] = b([1, 1]), [j, K] = b(), [h, v] = b([]), [p, E] = b(x || !1), A = (t, o) => {
46
+ }), [re, A] = x([1, 1]), [M, H] = x(), [b, v] = x([]), [y, P] = x(k || !1), T = (t, o) => {
47
47
  if (!e)
48
48
  return;
49
49
  o || (o = {
50
50
  x: e.getCenter().left,
51
51
  y: e.getCenter().top
52
52
  });
53
- let n = e.getZoom();
54
- n *= J(0.999, t), n > 20 && (n = 20), n < 0.01 && (n = 0.01), e.zoomToPoint(
53
+ let r = e.getZoom();
54
+ r *= Q(0.999, t), r > 20 && (r = 20), r < 0.01 && (r = 0.01), e.zoomToPoint(
55
55
  o,
56
- n
56
+ r
57
57
  // 传入修改后的缩放级别
58
- ), S([n, n]);
58
+ ), A([r, r]);
59
59
  };
60
- g(() => {
61
- h.forEach((t) => {
60
+ d(() => {
61
+ b.forEach((t) => {
62
62
  t.renderLabel();
63
63
  });
64
- }, [te, h, e]);
65
- const W = (t) => {
66
- var n;
67
- if (((n = t.target) == null ? void 0 : n.tagName) === "INPUT" || !e)
64
+ }, [re, b, e]);
65
+ const K = (t) => {
66
+ var r;
67
+ if (((r = t.target) == null ? void 0 : r.tagName) === "INPUT" || !e)
68
68
  return;
69
69
  const o = e == null ? void 0 : e.getActiveObject();
70
- o && v((i) => {
71
- const I = i.findIndex((z) => z.object === o);
72
- return i[I] && (i[I].destroy(), i.splice(I, 1)), f && f(i.map(k)), [...i];
70
+ o && v((n) => {
71
+ const g = n.findIndex((C) => C.object === o);
72
+ return n[g] && (n[g].destroy(), n.splice(g, 1)), f && f(n.map(E)), [...n];
73
73
  });
74
74
  };
75
- P("Delete", W), P("Backspace", W), P("ctrl", () => {
76
- E(!0);
75
+ O("Delete", K), O("Backspace", K), O("ctrl", () => {
76
+ P(!0);
77
77
  }, {
78
78
  events: ["keydown"]
79
- }), P("ctrl", () => {
80
- x || E(!1);
79
+ }), O("ctrl", () => {
80
+ k || P(!1);
81
81
  }, {
82
82
  events: ["keyup"]
83
- }), g(() => {
84
- E(x || !1);
85
- }, [x]);
83
+ }), d(() => {
84
+ P(k || !1);
85
+ }, [k]);
86
86
  const q = (t) => {
87
- e && $(e), v((o) => {
88
- const n = o.findIndex((i) => i === t);
89
- return n > -1 && (o.splice(n, 1), f && f(o.map(k)), Y()), [...o];
87
+ e && ee(e), v((o) => {
88
+ const r = o.findIndex((n) => n === t);
89
+ return r > -1 && (o.splice(r, 1), f && f(o.map(E)), U()), [...o];
90
90
  });
91
91
  }, F = (t) => {
92
92
  v((o) => {
93
- const n = o.findIndex((i) => i === t);
94
- return n > -1 && (o[n] = t, f && f(o.map(k))), [...o];
93
+ const r = o.findIndex((n) => n === t);
94
+ return r > -1 && (o[r] = t, f && f(o.map(E))), [...o];
95
95
  });
96
96
  };
97
- g(() => {
97
+ d(() => {
98
98
  if (!e)
99
99
  return;
100
100
  const t = [];
101
- return c.filter((o) => o.color).forEach((o) => {
102
- t.push(new _({
101
+ return l.filter((o) => o.color).forEach((o) => {
102
+ t.push(new V({
103
103
  id: o.id,
104
104
  name: o.label,
105
105
  color: o.color,
106
- points: o.box.map((n) => [n[0] + H.left, n[1] + H.top]),
107
- hideDelete: u
106
+ points: o.box.map((r) => [r[0] + W.left, r[1] + W.top]),
107
+ hideDelete: h
108
108
  }, e, {
109
109
  onChange: F,
110
110
  onDelete: q,
111
- renderLabelItem: O ? (n) => O ? O(o) : n.name : void 0
111
+ renderLabelItem: N ? (r) => N ? N(o) : r.name : void 0
112
112
  }));
113
113
  }), v(t), t.forEach((o) => {
114
114
  o.render(e);
@@ -117,199 +117,234 @@ const $ = (r) => {
117
117
  o.canvas !== e && o.destroy();
118
118
  });
119
119
  };
120
- }, [e, d]);
121
- const Y = () => {
122
- e && de(e, (t) => {
123
- const o = new _({
124
- id: (a == null ? void 0 : a.id) || t.id,
125
- name: (a == null ? void 0 : a.label) || t.label,
126
- color: (a == null ? void 0 : a.color) || t.color,
127
- points: t.box.map((n) => [n[0], n[1]]),
128
- hideDelete: u
120
+ }, [e, m]);
121
+ const U = () => {
122
+ e && ue(e, (t) => {
123
+ const o = new V({
124
+ id: (i == null ? void 0 : i.id) || t.id,
125
+ name: (i == null ? void 0 : i.label) || t.label,
126
+ color: (i == null ? void 0 : i.color) || t.color,
127
+ points: t.box.map((r) => [r[0], r[1]]),
128
+ hideDelete: h
129
129
  }, e, {
130
130
  onChange: F,
131
131
  onDelete: q
132
132
  });
133
- o.active = !0, h.push(o), f && f(h.map(k)), v([...h]);
134
- }, u);
135
- }, oe = () => {
133
+ o.active = !0, b.push(o), f && f(b.map(E)), v([...b]);
134
+ }, h);
135
+ }, ne = () => {
136
136
  let t = !1;
137
137
  e && (e.on("mouse:down", (o) => {
138
138
  t = !0, e.selection = !1;
139
139
  }), e.on("mouse:move", (o) => {
140
140
  if (t && o && o.e) {
141
- const n = new R.Point(o.e.movementX, o.e.movementY);
142
- e.relativePan(n);
141
+ const r = new z.Point(o.e.movementX, o.e.movementY);
142
+ e.relativePan(r);
143
143
  }
144
144
  }), e.on("mouse:up", (o) => {
145
145
  t = !1, e.selection = !0;
146
146
  }));
147
- }, ne = () => {
147
+ }, se = () => {
148
148
  e && (e.off("mouse:down"), e.off("mouse:move"), e.off("mouse:up"));
149
149
  };
150
- g(() => {
150
+ d(() => {
151
+ if (!e)
152
+ return;
153
+ const t = (o) => {
154
+ const r = e, n = r == null ? void 0 : r._currentTransform;
155
+ if (!n)
156
+ return;
157
+ const g = n.action;
158
+ if (!g || !g.startsWith("scale"))
159
+ return;
160
+ const C = e.backgroundImage, u = C == null ? void 0 : C.aCoords;
161
+ if (!u)
162
+ return;
163
+ const D = e.getPointer(o.e);
164
+ if (D.x < u.tl.x || D.x > u.br.x || D.y < u.tl.y || D.y > u.br.y) {
165
+ const w = r == null ? void 0 : r._onMouseUp;
166
+ typeof w == "function" && w(o.e);
167
+ }
168
+ };
169
+ return e.on("mouse:move", t), () => {
170
+ e.off("mouse:move", t);
171
+ };
172
+ }, [e]), d(() => {
173
+ if (!e)
174
+ return;
175
+ const t = (o) => {
176
+ const r = e;
177
+ if (!!!(r != null && r._currentTransform))
178
+ return;
179
+ const g = r == null ? void 0 : r._onMouseUp;
180
+ typeof g == "function" && g(o.e);
181
+ };
182
+ return e.on("mouse:out", t), () => {
183
+ e.off("mouse:out", t);
184
+ };
185
+ }, [e]), d(() => {
151
186
  if (e)
152
- return p ? (oe(), e.defaultCursor = "grab", e.on("mouse:down:before", () => {
187
+ return y ? (ne(), e.defaultCursor = "grab", e.on("mouse:down:before", () => {
153
188
  e.setCursor("grabbing");
154
189
  }), e.on("mouse:up", () => {
155
190
  e.defaultCursor = "grab";
156
191
  }), e.getObjects(), v((t) => (t.forEach((o) => {
157
- var n;
158
- return (n = o.object) == null ? void 0 : n.set("evented", !1);
192
+ var r;
193
+ return (r = o.object) == null ? void 0 : r.set("evented", !1);
159
194
  }), t))) : (e.defaultCursor = "default", e.off("mouse:down:before"), e.off("mouse:up"), e.setCursor("default"), v((t) => (t.forEach((o) => {
160
- var n;
161
- return (n = o.object) == null ? void 0 : n.set("evented", !0);
162
- }), t)), Y()), () => {
163
- ne();
195
+ var r;
196
+ return (r = o.object) == null ? void 0 : r.set("evented", !0);
197
+ }), t)), U()), () => {
198
+ se();
164
199
  };
165
- }, [e, p]), g(() => {
200
+ }, [e, y]), d(() => {
166
201
  if (e == null || e.on("mouse:wheel", (t) => {
167
202
  const o = t.e.deltaY;
168
- A(o, {
203
+ T(o, {
169
204
  x: t.e.offsetX,
170
205
  y: t.e.offsetY
171
- }), h.forEach((n) => {
172
- n.renderLabel();
206
+ }), b.forEach((r) => {
207
+ r.renderLabel();
173
208
  });
174
- }), !p)
175
- return Y(), () => {
176
- e && ($(e), e.off("mouse:wheel"));
209
+ }), !y)
210
+ return U(), () => {
211
+ e && (ee(e), e.off("mouse:wheel"));
177
212
  };
178
- }, [e, a, h, p]);
179
- const re = () => {
180
- V({}), U(void 0), S([1, 1]), e == null || e.dispose(), T(void 0);
213
+ }, [e, i, b, y]);
214
+ const ie = () => {
215
+ te({}), _(void 0), A([1, 1]), e == null || e.dispose(), Z(void 0);
181
216
  };
182
- return g(() => {
183
- B(!0), re(), !(!s.current || !d) && R.Image.fromURL(d, (t) => {
217
+ return d(() => {
218
+ B(!0), ie(), !(!a.current || !m) && z.Image.fromURL(m, (t) => {
184
219
  t.set({
185
220
  originX: "center",
186
221
  originY: "center"
187
- }), U(t), B(!1);
222
+ }), _(t), B(!1);
188
223
  }, {
189
224
  crossOrigin: "anonymous"
190
225
  });
191
- }, [d]), g(() => {
192
- if (!y && e) {
226
+ }, [m]), d(() => {
227
+ if (!I && e) {
193
228
  try {
194
229
  e.clear();
195
- } catch (M) {
230
+ } catch (Y) {
196
231
  }
197
232
  return;
198
233
  }
199
- if (!s.current || !s.current.parentElement)
234
+ if (!a.current || !a.current.parentElement)
200
235
  return;
201
- const t = y == null ? void 0 : y.getElement();
236
+ const t = I == null ? void 0 : I.getElement();
202
237
  if (!(t != null && t.width) || !(t != null && t.height))
203
238
  return;
204
- const o = t.width / t.height, n = s.current.parentElement.offsetWidth, i = s.current.parentElement.offsetHeight, I = n / t.width, z = i / t.height;
205
- let C = [n, i];
206
- I > z ? C = [i * o, i] : C = [n, n / o];
207
- const ae = C[0] / t.width, ie = C[1] / t.height, D = Math.min(ae, ie);
208
- S([D, D]);
209
- const m = new R.Canvas(s.current, {
239
+ const o = t.width / t.height, r = a.current.parentElement.offsetWidth, n = a.current.parentElement.offsetHeight, g = r / t.width, C = n / t.height;
240
+ let u = [r, n];
241
+ g > C ? u = [n * o, n] : u = [r, r / o];
242
+ const D = u[0] / t.width, G = u[1] / t.height, w = Math.min(D, G);
243
+ A([w, w]);
244
+ const p = new z.Canvas(a.current, {
210
245
  containerClass: "marking-canvas",
211
- width: n,
212
- height: i
246
+ width: r,
247
+ height: n
213
248
  });
214
- if (m == null || m.setZoom(D), m == null || m.renderAll(), m && y) {
215
- const M = (n - C[0]) / D / 2, G = (i - C[1]) / D / 2;
216
- m.setBackgroundImage(
217
- y,
249
+ if (p == null || p.setZoom(w), p == null || p.renderAll(), p && I) {
250
+ const Y = (r - u[0]) / w / 2, J = (n - u[1]) / w / 2;
251
+ p.setBackgroundImage(
252
+ I,
218
253
  () => {
219
- m.renderAll(), ee({
220
- left: M,
221
- top: G
222
- }), T(m), w && w();
254
+ p.renderAll(), oe({
255
+ left: Y,
256
+ top: J
257
+ }), Z(p), j && j();
223
258
  },
224
259
  // 刷新画布
225
260
  {
226
261
  originX: "left",
227
262
  originY: "top",
228
- left: M,
229
- top: G
263
+ left: Y,
264
+ top: J
230
265
  }
231
266
  );
232
267
  }
233
- }, [y]), g(() => {
234
- h.length > c.length && h.forEach((t) => {
235
- c.find((o) => o.id === t.config.id) || t.destroy();
268
+ }, [I]), d(() => {
269
+ b.length > l.length && b.forEach((t) => {
270
+ l.find((o) => o.id === t.config.id) || t.destroy();
236
271
  });
237
- }, [c.length]), g(() => {
238
- e && (p || v((t) => {
239
- const o = e == null ? void 0 : e.getActiveObject(), n = t.find((i) => i.object === o);
240
- return n && a && (n.labelConfig = {
241
- id: a.id,
242
- name: a.label,
243
- color: a.color
244
- }, f && f(t.map(k))), e && (a ? e.defaultCursor = "copy" : e.defaultCursor = "default"), [...t];
272
+ }, [l.length]), d(() => {
273
+ e && (y || v((t) => {
274
+ const o = e == null ? void 0 : e.getActiveObject(), r = t.find((n) => n.object === o);
275
+ return r && i && (r.labelConfig = {
276
+ id: i.id,
277
+ name: i.label,
278
+ color: i.color
279
+ }, f && f(t.map(E))), e && (i ? e.defaultCursor = "copy" : e.defaultCursor = "default"), [...t];
245
280
  }));
246
- }, [a, e, p]), g(() => {
281
+ }, [i, e, y]), d(() => {
247
282
  var t;
248
- if (N && s.current && !j) {
283
+ if (S && a.current && !M) {
249
284
  const o = document.createElement("div");
250
- o.setAttribute("style", "width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: absolute;top: 0;"), (t = s.current.parentElement) == null || t.appendChild(o), le.render(/* @__PURE__ */ l(ce, {}), o), K(o);
285
+ o.setAttribute("style", "width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: absolute;top: 0;"), (t = a.current.parentElement) == null || t.appendChild(o), ce.render(/* @__PURE__ */ c(le, {}), o), H(o);
251
286
  } else
252
- !N && j && (j.remove(), K(null));
253
- }, [N, s.current, j]), /* @__PURE__ */ Q("div", {
287
+ !S && M && (M.remove(), H(null));
288
+ }, [S, a.current, M]), /* @__PURE__ */ $("div", {
254
289
  style: {
255
290
  width: "100%",
256
291
  height: "100%",
257
292
  display: "flex"
258
293
  },
259
- children: [/* @__PURE__ */ l("div", {
294
+ children: [/* @__PURE__ */ c("div", {
260
295
  className: "marker-toolbar",
261
- children: /* @__PURE__ */ l("div", {
296
+ children: /* @__PURE__ */ c("div", {
262
297
  className: "create-mode-select",
263
- children: /* @__PURE__ */ Q(fe, {
298
+ children: /* @__PURE__ */ $(fe, {
264
299
  direction: "vertical",
265
300
  size: 16,
266
- children: [/* @__PURE__ */ l(X, {
301
+ children: [/* @__PURE__ */ c(R, {
267
302
  title: "放大-鼠标滚轮前滑",
268
303
  placement: "right",
269
- children: /* @__PURE__ */ l(Z, {
270
- icon: /* @__PURE__ */ l(ue, {}),
304
+ children: /* @__PURE__ */ c(X, {
305
+ icon: /* @__PURE__ */ c(de, {}),
271
306
  onClick: () => {
272
- A(-100);
307
+ T(-100);
273
308
  }
274
309
  })
275
- }), /* @__PURE__ */ l(X, {
310
+ }), /* @__PURE__ */ c(R, {
276
311
  title: "缩小-鼠标滚轮后滑",
277
312
  placement: "right",
278
- children: /* @__PURE__ */ l(Z, {
279
- icon: /* @__PURE__ */ l(me, {}),
313
+ children: /* @__PURE__ */ c(X, {
314
+ icon: /* @__PURE__ */ c(me, {}),
280
315
  onClick: () => {
281
- A(100);
316
+ T(100);
282
317
  }
283
318
  })
284
- }), !x && /* @__PURE__ */ l(X, {
319
+ }), !k && /* @__PURE__ */ c(R, {
285
320
  title: "拖动-按住ctrl",
286
321
  placement: "right",
287
- children: /* @__PURE__ */ l(Z, {
288
- disabled: x,
289
- icon: /* @__PURE__ */ l(ge, {}),
290
- className: p ? "active" : "",
322
+ children: /* @__PURE__ */ c(X, {
323
+ disabled: k,
324
+ icon: /* @__PURE__ */ c(ge, {}),
325
+ className: y ? "active" : "",
291
326
  onClick: () => {
292
- E(!p);
327
+ P(!y);
293
328
  }
294
329
  })
295
330
  })]
296
331
  })
297
332
  })
298
- }), /* @__PURE__ */ l("div", {
333
+ }), /* @__PURE__ */ c("div", {
299
334
  className: he({
300
335
  "label-maker-wrap": !0,
301
- draggable: p
336
+ draggable: y
302
337
  }),
303
338
  onContextMenu: (t) => {
304
339
  t.preventDefault();
305
340
  },
306
- children: /* @__PURE__ */ l("canvas", {
341
+ children: /* @__PURE__ */ c("canvas", {
307
342
  className: "label-maker-canvas",
308
- ref: s
343
+ ref: a
309
344
  })
310
345
  })]
311
346
  });
312
347
  };
313
348
  export {
314
- Ne as default
349
+ Le as default
315
350
  };
@@ -1,27 +1,58 @@
1
1
  import { useEffect as b } from "react";
2
- import { fabric as g } from "fabric";
3
- const j = ({
2
+ import { fabric as u } from "fabric";
3
+ const O = ({
4
4
  canvas: e,
5
- draggable: r,
6
- drawingMode: f
5
+ draggable: i,
6
+ drawingMode: f,
7
+ textLayersMapRef: n
7
8
  }) => {
9
+ const s = () => {
10
+ const c = /* @__PURE__ */ new Set();
11
+ return n.current.forEach((l) => {
12
+ l.forEach((r) => {
13
+ c.add(r);
14
+ });
15
+ }), c;
16
+ };
8
17
  b(() => {
9
18
  if (!e || f) {
10
- e && (e.selection = !1, e.skipTargetFind = !1, e.getObjects().forEach((t) => {
11
- t.set({
12
- evented: !0,
13
- selectable: !0,
14
- lockMovementX: !1,
15
- lockMovementY: !1,
16
- lockScalingX: !1,
17
- lockScalingY: !1
18
- });
19
- }), e.defaultCursor = "default", e.setCursor("default"));
19
+ if (e) {
20
+ e.selection = !1, e.skipTargetFind = !1;
21
+ const o = s();
22
+ e.getObjects().forEach((t) => {
23
+ t instanceof u.Rect && o.has(t) ? t.set({
24
+ evented: !0,
25
+ selectable: !1,
26
+ lockMovementX: !0,
27
+ lockMovementY: !0,
28
+ lockScalingX: !0,
29
+ lockScalingY: !0,
30
+ lockRotation: !0
31
+ }) : t.set({
32
+ evented: !0,
33
+ selectable: !0,
34
+ lockMovementX: !1,
35
+ lockMovementY: !1,
36
+ lockScalingX: !1,
37
+ lockScalingY: !1
38
+ });
39
+ }), e.defaultCursor = "default", e.setCursor("default");
40
+ }
20
41
  return;
21
42
  }
22
- if (!r) {
23
- e.selection = !1, e.skipTargetFind = !1, e.getObjects().forEach((t) => {
24
- t.set({
43
+ if (!i) {
44
+ e.selection = !1, e.skipTargetFind = !1;
45
+ const o = s();
46
+ e.getObjects().forEach((t) => {
47
+ t instanceof u.Rect && o.has(t) ? t.set({
48
+ evented: !0,
49
+ selectable: !1,
50
+ lockMovementX: !0,
51
+ lockMovementY: !0,
52
+ lockScalingX: !0,
53
+ lockScalingY: !0,
54
+ lockRotation: !0
55
+ }) : t.set({
25
56
  evented: !0,
26
57
  selectable: !0,
27
58
  lockMovementX: !1,
@@ -32,8 +63,8 @@ const j = ({
32
63
  }), e.defaultCursor = "default", e.setCursor("default");
33
64
  return;
34
65
  }
35
- e.selection = !1, e.skipTargetFind = !0, e.getActiveObject() && (e.discardActiveObject(), e.renderAll()), e.getObjects().forEach((t) => {
36
- t.set({
66
+ e.selection = !1, e.skipTargetFind = !0, e.getActiveObject() && (e.discardActiveObject(), e.renderAll()), e.getObjects().forEach((o) => {
67
+ o.set({
37
68
  evented: !1,
38
69
  selectable: !1,
39
70
  lockMovementX: !0,
@@ -43,22 +74,32 @@ const j = ({
43
74
  lockRotation: !0
44
75
  });
45
76
  }), e.defaultCursor = "grab";
46
- let o = !1;
47
- const i = (t) => {
48
- e.getActiveObject() && (e.discardActiveObject(), e.renderAll()), o = !0, e.selection = !1, e.skipTargetFind = !0, e.setCursor("grabbing");
49
- }, u = (t) => {
50
- if (o && t && t.e) {
51
- const l = t.e, d = new g.Point(l.movementX, l.movementY);
52
- e.relativePan(d);
77
+ let l = !1;
78
+ const r = (o) => {
79
+ e.getActiveObject() && (e.discardActiveObject(), e.renderAll()), l = !0, e.selection = !1, e.skipTargetFind = !0, e.setCursor("grabbing");
80
+ }, d = (o) => {
81
+ if (l && o && o.e) {
82
+ const t = o.e, m = new u.Point(t.movementX, t.movementY);
83
+ e.relativePan(m);
53
84
  }
54
- }, s = () => {
55
- o = !1, e.selection = !1, e.skipTargetFind = !0, e.defaultCursor = "grab", e.setCursor("grab"), e.getActiveObject() && (e.discardActiveObject(), e.renderAll());
56
- }, c = () => {
85
+ }, k = () => {
86
+ l = !1, e.selection = !1, e.skipTargetFind = !0, e.defaultCursor = "grab", e.setCursor("grab"), e.getActiveObject() && (e.discardActiveObject(), e.renderAll());
87
+ }, g = () => {
57
88
  e.setCursor("grabbing");
58
89
  };
59
- return e.on("mouse:down", i), e.on("mouse:move", u), e.on("mouse:up", s), e.on("mouse:down:before", c), () => {
60
- e.off("mouse:down", i), e.off("mouse:move", u), e.off("mouse:up", s), e.off("mouse:down:before", c), e.selection = !1, e.skipTargetFind = !1, e.getObjects().forEach((t) => {
61
- t.set({
90
+ return e.on("mouse:down", r), e.on("mouse:move", d), e.on("mouse:up", k), e.on("mouse:down:before", g), () => {
91
+ e.off("mouse:down", r), e.off("mouse:move", d), e.off("mouse:up", k), e.off("mouse:down:before", g), e.selection = !1, e.skipTargetFind = !1;
92
+ const o = s();
93
+ e.getObjects().forEach((t) => {
94
+ t instanceof u.Rect && o.has(t) ? t.set({
95
+ evented: !0,
96
+ selectable: !1,
97
+ lockMovementX: !0,
98
+ lockMovementY: !0,
99
+ lockScalingX: !0,
100
+ lockScalingY: !0,
101
+ lockRotation: !0
102
+ }) : t.set({
62
103
  evented: !0,
63
104
  selectable: !0,
64
105
  lockMovementX: !1,
@@ -68,8 +109,8 @@ const j = ({
68
109
  });
69
110
  });
70
111
  };
71
- }, [e, r, f]);
112
+ }, [e, i, f, n]);
72
113
  };
73
114
  export {
74
- j as useCanvasDrag
115
+ O as useCanvasDrag
75
116
  };