Skip to content

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

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

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