Skip to content

getCrop() returns whole percentages, losing sub-percent precision #36

Closed

Description

@paodb

Since the fix for #33 the crop state is kept as a % crop (onChange stores react-image-crop's percentCrop). Crop holds int values, so getCrop() rounds those percentages to whole units.

On a 4000px-wide image, 1% is 40px of granularity, and setCrop(getCrop()) visibly moves the selection. Previously onChange stored the pixel crop, so the granularity was roughly one rendered pixel.

Proposal: widen Crop's x, y, width and height from int to double. Note this changes the record's component types, so it is a breaking change for callers that read them — 1.3.0 would be the place for it.

Reported by @scardanzan while reviewing #35.

Activity

  1. moved this from Inbox (needs triage) to To Do in Flowing Code Addonson Oct 14, 2026
  2. added a commit that references this issue on Oct 15, 2026
    f44c645
  3. moved this from To Do to In Progress in Flowing Code Addonson Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions