canvu-react 0.4.24 → 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,15 +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 = [{ translateX: x }, { translateY: y }];
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
- return result;
1315
+ return [];
1316
+ }
1317
+ function skiaItemRotationOrigin(x, y, cx, cy) {
1318
+ return { x: x + cx, y: y + cy };
1317
1319
  }
1318
1320
  function rgbaFromHexAndOpacity(hex, opacity) {
1319
1321
  if (!hex) return hex;
@@ -2163,8 +2165,10 @@ function NativeInteractionOverlay({
2163
2165
  const b = normalizeRect(it.bounds);
2164
2166
  const cx = b.width / 2;
2165
2167
  const cy = b.height / 2;
2166
- const t = skiaItemPlacementTransform(it.x, it.y, cx, cy, it.rotation ?? 0);
2167
- 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(
2168
2172
  reactNativeSkia.Rect,
2169
2173
  {
2170
2174
  x: 0,
@@ -2176,7 +2180,11 @@ function NativeInteractionOverlay({
2176
2180
  strokeWidth: overlayStrokeWorld,
2177
2181
  antiAlias: true
2178
2182
  }
2179
- ) }, 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);
2180
2188
  }),
2181
2189
  showResizeHandles && bSingle && single && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2182
2190
  HANDLE_ORDER.map((hid) => {
@@ -2437,16 +2445,28 @@ function NativeInteractionOverlay({
2437
2445
  const b = normalizeRect(it.bounds);
2438
2446
  const cx = b.width / 2;
2439
2447
  const cy = b.height / 2;
2440
- const t = skiaItemPlacementTransform(it.x, it.y, cx, cy, it.rotation ?? 0);
2441
- 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(
2442
2452
  reactNativeSkia.Group,
2443
2453
  {
2444
- transform: t,
2454
+ transform: translationTransform,
2445
2455
  opacity: ERASER_PREVIEW_OPACITY,
2446
2456
  children: /* @__PURE__ */ jsxRuntime.jsx(NativeShapeRenderer, { item: it })
2447
2457
  },
2448
2458
  `erase-${it.id}`
2449
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
+ );
2450
2470
  }) });
2451
2471
  }, [eraserPreviewItems]);
2452
2472
  const eraserTrailElements = react.useMemo(() => {
@@ -2638,14 +2658,12 @@ var MemoShape = react.memo(function MemoShape2({
2638
2658
  const b = normalizeRect(item.bounds);
2639
2659
  const cx = b.width / 2;
2640
2660
  const cy = b.height / 2;
2641
- const itemTransform = skiaItemPlacementTransform(
2642
- item.x,
2643
- item.y,
2644
- cx,
2645
- cy,
2646
- item.rotation ?? 0
2647
- );
2648
- 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 });
2649
2667
  });
2650
2668
  function NativeSceneRenderer({
2651
2669
  items,