feat: add allowReverse option for resizing

This commit is contained in:
vector
2021-03-10 17:41:20 +08:00
parent ced000a647
commit d5e43d6020
3 changed files with 12 additions and 1 deletions

View File

@ -333,7 +333,10 @@ export class Transform extends Widget<Transform.Options> {
}
const relativeDirection = data.relativeDirection
if (rawWidth <= -width || rawHeight <= -height) {
if (
options.allowReverse &&
(rawWidth <= -width || rawHeight <= -height)
) {
let reverted: Node.ResizeDirection
if (relativeDirection === 'left') {
@ -537,6 +540,10 @@ export namespace Transform {
* aspect ratio of the node. Default is `false`.
*/
preserveAspectRatio?: boolean
/**
* Reaching the minimum width or height is whether to allow control points to reverse
*/
allowReverse?: boolean
}
}
@ -572,6 +579,7 @@ namespace Private {
orthogonalResizing: true,
restrictedResizing: false,
autoScrollOnResizing: true,
allowReverse: true,
}
}

View File

@ -242,6 +242,7 @@ export class Hook extends Base implements Hook.IHook {
resizing.restrict != null ? resizing.restrict : resizing.restricted,
autoScrollOnResizing: resizing.autoScroll,
preserveAspectRatio: resizing.preserveAspectRatio,
allowReverse: resizing.allowReverse,
rotatable: rotating.enabled,
rotateGrid: rotating.grid,

View File

@ -458,6 +458,7 @@ export namespace Options {
restricted?: boolean | number
autoScroll?: boolean
preserveAspectRatio?: boolean
allowReverse?: boolean
}
export type Resizing = {
@ -703,6 +704,7 @@ export namespace Options {
restricted: false,
autoScroll: true,
preserveAspectRatio: false,
allowReverse: true,
},
rotating: {
enabled: false,