Skip to content

Rotate left/right don't work as expected #7

@jasongerbes

Description

@jasongerbes

In the iOS photos app and Telegram app, the rotate button will always rotate the image by 90°, regardless of whether the user has previously adjusted the rotation via the slider.

However, the rotate left/right buttons in react-mobile-cropper will only rotate by 90° if the rotation slider is set to exactly 0°.

Reproduction steps

  1. Set the rotation slider to -20°.
  2. Press the 'rotate left' button.

Current behaviour

The rotation slider is reset to 0° and the image rotation is 'snapped' to -90°.

Expected behaviour

The rotation slider should still be set to -20° and the image should be rotated to -110°.

Additional context

This appears to be intentional behaviour, based on the rotateLeft and rotateRight functions in Navigation.tsx.

Changing these functions to always rotate by 90° introduces a new issue where the useLayoutEffect miscalculates the new adjustmentAngle if the rotation slider is set to exactly -45° or 45°.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions