Skip to content

Aspect Ratio #2

@SamirElkhatib

Description

@SamirElkhatib

Hello,
I'm trying to use this library to make a free-transform controlled component that preserves aspect ratio only when scaled from the corners (tr, tl, br, bl)...

My settings for the scale function look like this:

scale(
    scaleType,
    { startX, startY, x, y, scaleX, scaleY, width, height, angle, scaleLimit,
      scaleFromCenter: event.altKey,
      aspectRatio: true,
      enableAspectRatio: preserveAspectRatio,
    },
    onUpdate
);

preseveAspectRatio is sent true if scaleType is any of the corners

Issue:
Scaling still doesn't preserve aspect ratio except if shift key is pressed
the aspectRatio field seems to have no effect at all on the outcome. Also, after reviewing the source of scale.js I can't seem to understand this:

 if(!event.shiftKey && aspectRatio ){
      aspectRatio = false
} else if(event.shiftKey && !aspectRatio ){
      aspectRatio = true
}

The value of aspectRatio seems to be tied to event.shiftKey which makes it kind of neglected?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions