Skip to content
This repository has been archived by the owner on Aug 1, 2020. It is now read-only.

Allow cropper to grow vertically #350

Closed
dantman opened this issue Jun 21, 2015 · 4 comments
Closed

Allow cropper to grow vertically #350

dantman opened this issue Jun 21, 2015 · 4 comments

Comments

@dantman
Copy link
Contributor

dantman commented Jun 21, 2015

I'd like to have my (non-zoomable) cropper grow to fit the image (possibly up to a maximum size based on the viewport).

Like so.
screen shot 2015-06-21 at 12 55 36 pm

This sort of works fine if the image is visible before Cropper is loaded. As it uses the container height that has been extended by the visible image as a base.

However if the image was display: none;ed such as by react-cropper or simply by someone not wanting to show an unstyled flash of the image without the cropper. This happens.
screen shot 2015-06-21 at 12 59 17 pm

I think the ideal would be to have an option like growContainerVertical: true (and perhaps a maxContainerHeight). This way not only would it handle images that have been hidden, but it would also allow the height of the container to be recalculated

As an extra possibility perhaps maxContainerHeight could be permitted to be a function. In which case it would be re-run when Cropper's _resize handler is triggered.

@fengyuanchen
Copy link
Owner

I think you can set the container's size base on the image's size before start a cropper.

@dantman
Copy link
Contributor Author

dantman commented Jun 27, 2015

@fengyuanchen Yes. However some people might want to avoid the Min height box -> Loaded image -> Cropper and go straight from the (hidden) image to the cropper.

Also, that only applies when you first load the cropper. If you use replace it wouldn't inherit new heights from the image.

@dantman
Copy link
Contributor Author

dantman commented Jul 1, 2015

I also ended up with my cropper recently unexpectedly working different. opacity: 0 was being used so the cropper would inherit the image height. Before it inherited the height. Now it doesn't.

Which makes me think that it is much better for cropper to be responsible for sizes of things instead of relying on a context that allows potential race conditions and/or browser inconsistencies.

@fengyuanchen
Copy link
Owner

After a few tests, I found this is a bug of the replace method left over by history. Thank you very much. I will improve it soon.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants