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.
In the current setup, if you have
dynamicSizing
on, a resize listener gets added towindow
, 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.