goatdee-canvas 0.0.65 → 0.0.67

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.
Binary file
package/dist/index.cjs CHANGED
@@ -2083,6 +2083,22 @@ const getScale = () => {
2083
2083
  return 1;
2084
2084
  }
2085
2085
  };
2086
+ /**
2087
+ * 获取当前画布偏移量(内容坐标系下的平移分量)。
2088
+ * @category 画布操作
2089
+ * @returns 偏移量 \{ x, y \};失败时返回 null
2090
+ */
2091
+ const getOffset = () => {
2092
+ try {
2093
+ const canvas = manager.getCanvas();
2094
+ const jsonStr = canvas.getOffset();
2095
+ return jsonStr ? JSON.parse(jsonStr) : null;
2096
+ }
2097
+ catch (error) {
2098
+ console.warn("Canvas operation(getOffset) failed:", error);
2099
+ return null;
2100
+ }
2101
+ };
2086
2102
  /**
2087
2103
  * 获取当前选中的对象列表。
2088
2104
  * @category 对象操作
@@ -3054,6 +3070,7 @@ var ManagerAPI = /*#__PURE__*/Object.freeze({
3054
3070
  getCrop: getCrop,
3055
3071
  getIndex: getIndex,
3056
3072
  getObject: getObject,
3073
+ getOffset: getOffset,
3057
3074
  getParentLayer: getParentLayer,
3058
3075
  getScale: getScale,
3059
3076
  getTextLayerSelection: getTextLayerSelection,
@@ -4176,6 +4193,7 @@ function useCanvasImperativeHandle(ref, args) {
4176
4193
  viewportToCanvas: (clientX, clientY) => viewportToCanvas(clientX, clientY),
4177
4194
  canvasToViewport: (layoutX, layoutY) => canvasToViewport(layoutX, layoutY),
4178
4195
  getScale: () => { var _a, _b; return (_b = (_a = canvasPtr.current) === null || _a === void 0 ? void 0 : _a.getScale()) !== null && _b !== void 0 ? _b : 1; },
4196
+ getOffset: () => getOffset(),
4179
4197
  getActiveObjects: () => getActiveObjects(),
4180
4198
  getObject: (id) => getObject(id),
4181
4199
  getBounds: () => getBounds(),