fix group mask image

This commit is contained in:
hamid zarghami
2026-01-04 15:25:21 +03:30
parent 19258395a0
commit bbf7167993
3 changed files with 45 additions and 18 deletions
@@ -16,11 +16,15 @@ const ImageObject = ({
const shapeRef = useRef<Konva.Image>(null);
useEffect(() => {
// اگر draggable=false باشد، یعنی mask اعمال شده و transformer باید به Group متصل شود (نه Image)
// پس این useEffect را اجرا نکن
if (!draggable) return;
if (isSelected && shapeRef.current && transformerRef.current && image) {
transformerRef.current.nodes([shapeRef.current]);
transformerRef.current.getLayer()?.batchDraw();
}
}, [isSelected, transformerRef, image]);
}, [isSelected, transformerRef, image, draggable]);
if (!image) return null;
@@ -33,15 +37,17 @@ const ImageObject = ({
image={image}
width={obj.width || image.width}
height={obj.height || image.height}
stroke={isSelected ? "#3b82f6" : undefined}
strokeWidth={isSelected ? 3 : 0}
// اگر draggable=false باشد، یعنی mask اعمال شده و نباید stroke نمایش داده شود (Group stroke دارد)
stroke={isSelected && draggable ? "#3b82f6" : undefined}
strokeWidth={isSelected && draggable ? 3 : 0}
rotation={obj.rotation || 0}
draggable={draggable}
onClick={() => {
onClick={draggable ? () => {
// فقط وقتی mask اعمال نشده onClick handler را فعال کن
if (shapeRef.current) {
onSelect(obj.id, shapeRef.current);
}
}}
} : undefined}
onDragEnd={(e) => {
const node = e.target;
onUpdate(obj.id, {