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

Cropper instance created twice when recreate after destroy #306

Closed
1 task done
supachailllpay opened this issue Feb 27, 2018 · 0 comments
Closed
1 task done

Cropper instance created twice when recreate after destroy #306

supachailllpay opened this issue Feb 27, 2018 · 0 comments

Comments

@supachailllpay
Copy link

Current behavior

In my application I use cropperjs inside modal. When modal pop up I initialize cropper instance with:

cropper = new Cropper(image)

then If user close modal, I will destroy it with:

cropper.destroy()

So if user open modal again it will initialize cropper instance again except sometime cropper instance has created twice.

Minimal reproduction of the problem with instructions

I create jsfiddle, click toggle (or re-run) over and over you will see two cropper instances.

Browser:

  • Chrome (desktop) version 64

My debugging

After debugging I found start method had called twice which I think one come from normal behavior and another one come from load listener which (If I understand your code correctly) it should destroy in start method here.

In pervious version(v1.2.2) everything works fine, this behavior just appear in new version (v1.3.0). So I look into files changed between 2 versions and found this.

In my opinion I think set onload to null cannot remove listener from addEventListener.

I hope this information will help you.
Thank you.

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

No branches or pull requests

1 participant