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

Trying to restore previous crop data #624

Closed
orderwerks opened this issue Jun 6, 2021 · 10 comments
Closed

Trying to restore previous crop data #624

orderwerks opened this issue Jun 6, 2021 · 10 comments

Comments

@orderwerks
Copy link

I'm using v2.1.7 and when I pull the crop data using cropperRef.getData() and then pass this to the component property data, the previous crop data doesn't restore on the image:

<Cropper
    data={previousCropData}
    />

I've also tried setting this using the onInitialized callback, but same issue:

<Cropper
    onInitialized={(instance) => {
        instance.setData(previousCropData);
    }}
/>

I've also tried passing in getCropBoxData() object as well to the same effect. Am I doing this correctly? or is this broken?

Thanks.

@orderwerks orderwerks added the bug label Jun 6, 2021
@shekhar-shubhendu
Copy link
Collaborator

@orderwerks Thanks for reporting this. If you can make me a codesandbox with the issue, I can look into it and check what is the issue.

@SpencerRohan
Copy link

SpencerRohan commented Jun 9, 2021

@shekhar-shubhendu If you utilize the demo and add data={{ height: 140, rotate: 45, scaleX: 1, scaleY: 1, width: 140, x: 21, y: 56 }} it appears not to do anything.

@SpencerRohan
Copy link

This now seems resolved with v2.1.8

@orderwerks
Copy link
Author

orderwerks commented Jun 30, 2021

There still is a bug with it...

set the package.json in the demo to 2.1.8,

and set the data to:

data={{
  height: 400,
  rotate: 0,
  scaleX: 1,
  scaleY: 1,
  width: 400,
  x: 0,
  y: 0
}}

The crop box won't restore to y = 0. It respects x = 0, but for some reason won't allow y = 0.

@SpencerRohan
Copy link

SpencerRohan commented Jun 30, 2021

Screen Shot 2021-06-30 at 12 48 57 PM

@orderwerks I am getting it to work with the data provided above. Did you try and hit the refresh button inside the preview window(dumb question)?

2.1.6 & 2.1.7 definitely didn't work.
2.1.5 didn't have this issue.

@orderwerks
Copy link
Author

Definitely hit refresh, multiple times:

image

@shekhar-shubhendu
Copy link
Collaborator

@SpencerRohan
Copy link

SpencerRohan commented Jul 1, 2021

I was able to reproduce what @orderwerks is getting on 2.1.8, it appears the positioning changes between screen widths.

To Reproduce:

  1. Set data property to above.
  2. Refresh preview
  3. Make browser window smaller
  4. Refresh preview

It most certainly doesn't look like the set data button results in @shekhar-shubhendu link, but the set data workaround does work for me in the link above.

@stale
Copy link

stale bot commented Jul 31, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 31, 2021
@stale
Copy link

stale bot commented Aug 7, 2021

Closing as there was no activity. Please reopen if required.

@stale stale bot closed this as completed Aug 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants