Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/core/ServersPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ class ServersPlugin implements IPluginTempl {
textPaths.push({ id: item.id, path: item.path });
item.path = null;
}
// 设置锁定对象
if(item.extension?.isLocked) {
item.lockMovementX = true
item.lockMovementY = true
item.lockRotation = true
item.lockScalingX = true
item.lockScalingY = true
}
});

// hookTransform遍历
Expand Down
10 changes: 10 additions & 0 deletions packages/core/plugin/LockPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ export default class LockPlugin implements IPluginTempl {
lock() {
const activeObject = this.canvas.getActiveObject() as fabric.Object;
if (activeObject) {
// 确保 extension 对象存在
if (!activeObject.extension) {
activeObject.extension = {}
}
// 在 extension 中设置锁定状态
activeObject.extension.isLocked = true
// 修改默认属性
Object.values(ItypeKey).forEach((key: ItypeKey) => {
activeObject[key] = true;
Expand All @@ -197,6 +203,10 @@ export default class LockPlugin implements IPluginTempl {
activeObject.hasControls = true;
activeObject.selectable = true;
activeObject.evented = true;
// 清除 extension 中的锁定状态
if (activeObject.extension) {
activeObject.extension.isLocked = false
}
// 修改默认属性
Object.values(ItypeKey).forEach((key: ItypeKey) => {
activeObject[key] = false;
Expand Down