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

new-image-drawn event not fired when image added with chooseFile() method #124

Closed
rwfresh opened this issue Jul 11, 2018 · 11 comments
Closed
Labels

Comments

@rwfresh
Copy link

rwfresh commented Jul 11, 2018

When adding a new image to a croppa instance using the chooseFile() method the new-image-drawn event is not fired.

https://codepen.io/anon/pen/zLYQVz

Not necessarily a bug as you can force hasImage() to false by using remove() before the new image is selected which will result in the event being emitted.

In my case I'd like to replace the existing image and still have the event fired so that the new image will be sized correctly according to my initial-size prop value

@zhanziyang
Copy link
Owner

zhanziyang commented Jul 11, 2018

I tried the demo and the event was fired. I record the screen:

https://www.useloom.com/share/d88cec876178418a8647adbcca24c108

@rwfresh
Copy link
Author

rwfresh commented Jul 11, 2018

Load one and then use the chooseFile() to load another. Only fires on the first load.

https://www.useloom.com/share/effcb66e92854f118d4d1f460c6e0d7c

My use case is a profile image. The user may already have a profile image and may choose to edit the existing image OR replace it with a new one. In this case I pass an initial image prop and so I must display a button with chooseFile(). Since an initial image is loaded on init adding a replacement image does not fire the new-image-drawn event. Try for yourself with the same codepen.

The work around is to remove() the initial image before the second one is added. The problem here is if the user cancels the file input there is no way to capture that event and replace the initial image.

@zhanziyang
Copy link
Owner

@rwfresh Indeed. Will fix the bug. Please use remove() for now.

@zhanziyang zhanziyang added the bug label Jul 12, 2018
@rwfresh
Copy link
Author

rwfresh commented Jul 12, 2018

@zhanziyang Thank you very much for making this component. I really appreciate it. I went through the code to see if I could modify and make a pull request but I haven't had enough time to actually track it down.

@rwfresh
Copy link
Author

rwfresh commented Jul 12, 2018

Also, might be of value for other users, I have a demo where I place an overlay that helps end users frame their image much like linkedIn's profile image editor. This fix will make it run much smoother. I will create a codepen demo.

@zhanziyang
Copy link
Owner

@rwfresh Sounds awesome!

@zhanziyang
Copy link
Owner

@rwfresh Bug fixed in new version 1.3.7. Please upgrade : )

@rwfresh
Copy link
Author

rwfresh commented Jul 23, 2018

Hi @zhanziyang Thanks for this fix. Finally had a chance to review my code. Here's a codepen with the overlay I was talking about. https://codepen.io/rwfresh/pen/zLYQVz

@zhanziyang
Copy link
Owner

Thanks @rwfresh. That's a cool demo. Maybe later I will add it to the demo page.

@rwfresh
Copy link
Author

rwfresh commented Aug 1, 2018

@zhanziyang right on. Again, thanks to you for taking the time to put this together.

@spham
Copy link

spham commented Dec 2, 2019

@zhanziyang , it seems not update in demo.

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

No branches or pull requests

3 participants