cstefanache / angular2-img-cropper

Angular 2 Image Cropper
MIT License
364 stars 135 forks source link

Remove resize event listener on destroy #192

Closed zbarbuto closed 7 years ago

zbarbuto commented 7 years ago

In the current setup, if you have dynamicSizing on, a resize listener gets added to window, but never removed (leaks).

This causes issues if, say, you have the image cropper in a modal, which is then closed. The resize listener keeps trying to update the canvas whenever the window is resized, but the canvas is gone, causing errors to be thrown.

It also means every time a new image cropper is spawned, another listener is added to the window.

This cleans up the window listener when the image cropper component is destroyed.

cstefanache commented 7 years ago

Thanks!