mirror of
https://github.com/idrawjs/idraw
synced 2026-05-24 10:08:34 +00:00
feat: @idraw/core limit element num and angle
This commit is contained in:
parent
42e0fb609a
commit
be53d035ec
1 changed files with 13 additions and 2 deletions
|
|
@ -3,8 +3,8 @@ import {
|
|||
TypePoint,
|
||||
TypeData,
|
||||
TypeHelperWrapperDotDirection,
|
||||
// TypeElement,
|
||||
// TypeElemDesc,
|
||||
TypeElement,
|
||||
TypeElemDesc,
|
||||
} from '@idraw/types';
|
||||
import util from '@idraw/util';
|
||||
import { rotateElement } from './transform';
|
||||
|
|
@ -74,6 +74,7 @@ export class Element {
|
|||
const moveY = point.y - prevPoint.y;
|
||||
data.elements[index].x += (moveX / scale);
|
||||
data.elements[index].y += (moveY / scale);
|
||||
this.limitElementAttrs(data.elements[index]);
|
||||
}
|
||||
|
||||
transformElement(
|
||||
|
|
@ -167,6 +168,8 @@ export class Element {
|
|||
}
|
||||
}
|
||||
|
||||
this.limitElementAttrs(elem);
|
||||
|
||||
return {
|
||||
width: limitNum(elem.w),
|
||||
height: limitNum(elem.h),
|
||||
|
|
@ -184,5 +187,13 @@ export class Element {
|
|||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
limitElementAttrs(elem: TypeElement<keyof TypeElemDesc>) {
|
||||
elem.x = limitNum(elem.x);
|
||||
elem.y = limitNum(elem.y);
|
||||
elem.w = limitNum(elem.w);
|
||||
elem.h = limitNum(elem.h);
|
||||
elem.angle = limitAngle(elem.angle || 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue