zhanziyang / vue-croppa

A simple straightforward customizable mobile-friendly image cropper for Vue 2.0.
https://zhanziyang.github.io/vue-croppa/
ISC License
967 stars 128 forks source link

Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'. #85

Closed alex-oleksenko closed 6 years ago

alex-oleksenko commented 6 years ago

I am using vue-croppa component in modal dialog and experience this issue after closing my dialog during window resize.

I have investigated the issue and figured out that auto-sizing = true is the property what affects on that. The problem is with resize event listener in _setSize function.

I would suggest to use mounted method to add event listener and beforeDestroy method to remove event listener as well.

zhanziyang commented 6 years ago

It seems the new feature auto-sizing has caused a lot of problems : ((((( #83 also. I will look into it and do the fix asap, probably in two days though, because I'm a little busy at my job lately. If it's urgent I suggest you can handle the dynamic resizing in the old way, which is to dynamically change the value for :width and :height prop. And thanks for your suggestion, mate.

zhanziyang commented 6 years ago

This issue should be fixed in the newly released version v1.3.1. Please confirm.

alex-oleksenko commented 6 years ago

No, looks like nothing was changed and it still doesn't work as expected.

zhanziyang commented 6 years ago

This is what changed: https://github.com/zhanziyang/vue-croppa/blob/29ad64a3ed82e91e52bf6a3533d49789147a559a/src/cropper.vue#L502-L512

This method is called in mounted https://github.com/zhanziyang/vue-croppa/blob/29ad64a3ed82e91e52bf6a3533d49789147a559a/src/cropper.vue#L193

I can't reproduce the error. It would be great if you have time to fix it and submit a pull request.

zhanziyang commented 6 years ago

Would you give v1.3.3 a try?

alex-oleksenko commented 6 years ago

@zhanziyang yes, it was fixed in version 1.3.3

But any way I would suggest to improve you code a little bit more. You have to call removeEventListener method for resize event in beforeDestroy vuejs hook method, it allows you to avoid calling setContainerSize method for already destroyed instances.

I have created appropriate pull request.

zhanziyang commented 6 years ago

@alex-oleksenko You are right. I forgot about that one. Thanks for the PR.