Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add for choosing rotation direction #32

Merged
merged 2 commits into from
Jul 11, 2024

Conversation

iqorlobanov
Copy link
Contributor

When using this package, I noticed that it does not have the option to rotate the image counterclockwise. In my case, I just needed to rotate the image counterclockwise and I decided to add a new function rotateWithDirection

What's been added

rotateWithDirection

Rotate the component 90 degrees (or -90 degrees) clockwise or counterclockwise in a range from 0 to 360 degrees (or 0 to -360 degrees).

  • Arguments
Name Type Default Description
animate boolean | undefined true Whether to animate the transition or not.
clockwise boolean | undefined true Whether to rotate clockwise (90 degrees) or counterclockwise (-90 degrees)
cb function | undefined undefined Callback to trigger at the beginning of the transition, as its only argument receives the angle your component will transition to, this angle ranges from 0 to 360 degrees (or -360 degrees) (at 360 or -360 degrees it's clamped to 0).
  • Returns void

How it works

const clockwiseRotation = true; // Use `false` for counterclockwise rotation
cropZoomRef.current?.rotateWithDirection(true, clockwiseRotation, (radians) => {
    // Convert the rotation angle from radians to degrees
    const rotationAngle = radians * (180 / Math.PI);

    console.log(rotationAngle);
});

@Glazzes
Copy link
Owner

Glazzes commented Jul 11, 2024

Hi there, excuse me for the late response, I have been considering whether this could make a good addittion to the library or not, I think it may good for the library at least for now until the next major both rotate methods get collapsed into a single one.

Did you manually test whether the direction produced accurate crops? By accurate I mean what you see on screen it's what you get as a result.

@iqorlobanov
Copy link
Contributor Author

Did you manually test whether the direction produced accurate crops? By accurate I mean what you see on screen it's what you get as a result.

Yes, everything has been tested on both platforms

@Glazzes
Copy link
Owner

Glazzes commented Jul 11, 2024

Alright then, everything is looking good to me.

@Glazzes Glazzes merged commit 4cf7f81 into Glazzes:main Jul 11, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants