canvu-react 0.4.25 → 0.4.26

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/dist/native.cjs CHANGED
@@ -1305,16 +1305,17 @@ function parseSvgTransform(s) {
1305
1305
  function skiaCameraTransform(zoom, panX, panY) {
1306
1306
  return [{ translateX: panX }, { translateY: panY }, { scale: zoom }];
1307
1307
  }
1308
- function skiaItemPlacementTransform(x, y, cx, cy, rotationRad) {
1309
- const result = [];
1308
+ function skiaItemTranslationTransform(x, y) {
1309
+ return [{ translateX: x }, { translateY: y }];
1310
+ }
1311
+ function skiaItemRotationTransform(rotationRad) {
1310
1312
  if (Math.abs(rotationRad) > 1e-12) {
1311
- result.push({
1312
- rotate: rotationRad,
1313
- origin: { x: cx, y: cy }
1314
- });
1313
+ return [{ rotate: rotationRad }];
1315
1314
  }
1316
- result.push({ translateX: x }, { translateY: y });
1317
- return result;
1315
+ return [];
1316
+ }
1317
+ function skiaItemRotationOrigin(x, y, cx, cy) {
1318
+ return { x: x + cx, y: y + cy };
1318
1319
  }
1319
1320
  function rgbaFromHexAndOpacity(hex, opacity) {
1320
1321
  if (!hex) return hex;
@@ -2164,8 +2165,10 @@ function NativeInteractionOverlay({
2164
2165
  const b = normalizeRect(it.bounds);
2165
2166
  const cx = b.width / 2;
2166
2167
  const cy = b.height / 2;
2167
- const t = skiaItemPlacementTransform(it.x, it.y, cx, cy, it.rotation ?? 0);
2168
- return /* @__PURE__ */ jsxRuntime.jsx(reactNativeSkia.Group, { transform: t, children: /* @__PURE__ */ jsxRuntime.jsx(
2168
+ const rotationTransform = skiaItemRotationTransform(it.rotation ?? 0);
2169
+ const rotationOrigin = skiaItemRotationOrigin(it.x, it.y, cx, cy);
2170
+ const translationTransform = skiaItemTranslationTransform(it.x, it.y);
2171
+ const selectionRect = /* @__PURE__ */ jsxRuntime.jsx(reactNativeSkia.Group, { transform: translationTransform, children: /* @__PURE__ */ jsxRuntime.jsx(
2169
2172
  reactNativeSkia.Rect,
2170
2173
  {
2171
2174
  x: 0,
@@ -2177,7 +2180,11 @@ function NativeInteractionOverlay({
2177
2180
  strokeWidth: overlayStrokeWorld,
2178
2181
  antiAlias: true
2179
2182
  }
2180
- ) }, it.id);
2183
+ ) });
2184
+ if (rotationTransform.length === 0) {
2185
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNativeSkia.Group, { children: selectionRect }, it.id);
2186
+ }
2187
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNativeSkia.Group, { transform: rotationTransform, origin: rotationOrigin, children: selectionRect }, it.id);
2181
2188
  }),
2182
2189
  showResizeHandles && bSingle && single && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2183
2190
  HANDLE_ORDER.map((hid) => {
@@ -2438,16 +2445,28 @@ function NativeInteractionOverlay({
2438
2445
  const b = normalizeRect(it.bounds);
2439
2446
  const cx = b.width / 2;
2440
2447
  const cy = b.height / 2;
2441
- const t = skiaItemPlacementTransform(it.x, it.y, cx, cy, it.rotation ?? 0);
2442
- return /* @__PURE__ */ jsxRuntime.jsx(
2448
+ const rotationTransform = skiaItemRotationTransform(it.rotation ?? 0);
2449
+ const rotationOrigin = skiaItemRotationOrigin(it.x, it.y, cx, cy);
2450
+ const translationTransform = skiaItemTranslationTransform(it.x, it.y);
2451
+ const preview = /* @__PURE__ */ jsxRuntime.jsx(
2443
2452
  reactNativeSkia.Group,
2444
2453
  {
2445
- transform: t,
2454
+ transform: translationTransform,
2446
2455
  opacity: ERASER_PREVIEW_OPACITY,
2447
2456
  children: /* @__PURE__ */ jsxRuntime.jsx(NativeShapeRenderer, { item: it })
2448
2457
  },
2449
2458
  `erase-${it.id}`
2450
2459
  );
2460
+ if (rotationTransform.length === 0) return preview;
2461
+ return /* @__PURE__ */ jsxRuntime.jsx(
2462
+ reactNativeSkia.Group,
2463
+ {
2464
+ transform: rotationTransform,
2465
+ origin: rotationOrigin,
2466
+ children: preview
2467
+ },
2468
+ `erase-rot-${it.id}`
2469
+ );
2451
2470
  }) });
2452
2471
  }, [eraserPreviewItems]);
2453
2472
  const eraserTrailElements = react.useMemo(() => {
@@ -2639,14 +2658,12 @@ var MemoShape = react.memo(function MemoShape2({
2639
2658
  const b = normalizeRect(item.bounds);
2640
2659
  const cx = b.width / 2;
2641
2660
  const cy = b.height / 2;
2642
- const itemTransform = skiaItemPlacementTransform(
2643
- item.x,
2644
- item.y,
2645
- cx,
2646
- cy,
2647
- item.rotation ?? 0
2648
- );
2649
- return /* @__PURE__ */ jsxRuntime.jsx(reactNativeSkia.Group, { transform: itemTransform, children: /* @__PURE__ */ jsxRuntime.jsx(NativeShapeRenderer, { item }) });
2661
+ const rotationTransform = skiaItemRotationTransform(item.rotation ?? 0);
2662
+ const rotationOrigin = skiaItemRotationOrigin(item.x, item.y, cx, cy);
2663
+ const translationTransform = skiaItemTranslationTransform(item.x, item.y);
2664
+ const shape = /* @__PURE__ */ jsxRuntime.jsx(reactNativeSkia.Group, { transform: translationTransform, children: /* @__PURE__ */ jsxRuntime.jsx(NativeShapeRenderer, { item }) });
2665
+ if (rotationTransform.length === 0) return shape;
2666
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNativeSkia.Group, { transform: rotationTransform, origin: rotationOrigin, children: shape });
2650
2667
  });
2651
2668
  function NativeSceneRenderer({
2652
2669
  items,