divyanshu013/react-animated-weather

Non animated icons do not resize

georgelioris opened this issue · 1 comments

Expected Behavior

Changing the size property of the component resizes the icon.

Current Behavior

The icon disappears if animate={false} was specified.

Detailed Description

This behavior only happens on non animated icons.
On animated icons, the draw() function in skycons.js get's called at an interval, and if
resizeClear: true is not specified it will redraw based on canvas size. As a result, animated icons will always resize properly, even though size is not a dependency of the useEffect hook.

Context

This a result of #15 I submitted to refactor the component. Hence, I'm sending another to fix this soon.

Possible Implementation

Adding the size as a dependency is the easiest solution.
Also the class should be instantiated with resizeClear: true since not specifying it now is redundant.

I am aware that this is somewhat sub-optimal but after spending some time implementing a resize method, I believe this is the safest way to go without major refactors.

Fixed in #17. Thanks for contributing.