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
aspectRatio not working #571
Comments
@grighth12 you need to use the cropper instance or ref to change the aspect ratio after initialisation |
@shekhar-shubhendu how do I update the aspect ratio after that has been done? Similar to this demo https://fengyuanchen.github.io/cropperjs/ . In that code .destroy() is called on the instance and then a new one is recreated from image and options. So I have a working cropper with a locked in aspect ratio. But I want the same button group with different aspect ratios so that I can switch between them. EDIT: It is actually working, what I'm missing is the blue cropperbox updating it's ratio. That happens only after I try to resize it. I would like for it to happen on button click EDIT#2: I made it work by setting size to width++ and width-- directly after. It does update the cropped area size to obide by the new aspectRatio.
|
@LordTep Thanks. I will check if this can be also handled. |
@LordTep
There was a problem with the screen blinking when the ratio changed. EDIT : and i tried console.log(ref.current.getData()) but there's an error "TypeError: ref.current.getData is not a function". How did you do it?? @shekhar-shubhendu It's not a completely accurate code, but I did it like this. simple codesandbox: https://codesandbox.io/s/react-cropper-ratio-o8p5g?file=/src/Demo.tsx do you have any other ideas? |
@shekhar-shubhendu cool thanks, |
is this something that you want? |
@shekhar-shubhendu that's perfect! Thanks |
@shekhar-shubhendu Thank you!!!!!!!!!!! <3<3 That's exactly what I wanted!!! |
I want to make a crop area ratio that changes with the click of a button. Declared the ratio to state and set it to aspectRatio for the Cropper component.
Like this,
const [ratio, setRatio] = useState(1); .... <Cropper ... aspectRatio={ratio} ... />
However, even if the ratio changes, there is no change in the screen.
I added a button to the demo to set the ratio. but it's not working
Here is codesandbox : https://codesandbox.io/s/react-cropper-ratio-o8p5g?file=/src/Demo.tsx:1319-1900
any solution?
The text was updated successfully, but these errors were encountered: