add setting diable/enable smart guide
This commit is contained in:
@@ -39,6 +39,7 @@ const EditorCanvas = ({ catalogSize }: EditorCanvasProps) => {
|
||||
tool,
|
||||
objects,
|
||||
guides,
|
||||
documentSettings,
|
||||
pages,
|
||||
currentPageId,
|
||||
selectedObjectId,
|
||||
@@ -50,6 +51,7 @@ const EditorCanvas = ({ catalogSize }: EditorCanvasProps) => {
|
||||
setGuides,
|
||||
zoom,
|
||||
} = useEditorStore();
|
||||
const isSmartGuideEnabled = documentSettings.smartGuide;
|
||||
const currentPage = pages.find((page) => page.id === currentPageId);
|
||||
|
||||
const bgColor =
|
||||
@@ -307,6 +309,11 @@ const EditorCanvas = ({ catalogSize }: EditorCanvasProps) => {
|
||||
const handleDragMove = (e: Konva.KonvaEventObject<DragEvent>) => {
|
||||
const node = e.target;
|
||||
if (!node || node.name() === "guide-line") return;
|
||||
if (!isSmartGuideEnabled) {
|
||||
updateActiveGuides([]);
|
||||
clearSmartGuides(smartGuidesLayerRef.current);
|
||||
return;
|
||||
}
|
||||
|
||||
const snapped = getSnappedPosition(node, guides, finalScale);
|
||||
|
||||
@@ -338,6 +345,12 @@ const EditorCanvas = ({ catalogSize }: EditorCanvasProps) => {
|
||||
clearSmartGuides(smartGuidesLayerRef.current);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (isSmartGuideEnabled) return;
|
||||
updateActiveGuides([]);
|
||||
clearSmartGuides(smartGuidesLayerRef.current);
|
||||
}, [isSmartGuideEnabled]);
|
||||
|
||||
const handleStageMouseDownWithGuideReset = (e: Konva.KonvaEventObject<MouseEvent>) => {
|
||||
if (e.target?.name() !== "guide-line") {
|
||||
setSelectedGuideId(null);
|
||||
|
||||
Reference in New Issue
Block a user