Chronostasys / Blazor.Cropper

A blazor library provides component to crop image
MIT License
84 stars 19 forks source link

Fix RatioChanged causing an infinite loop #9

Closed Dnawrkshp closed 3 years ago

Dnawrkshp commented 3 years ago

In my local project, RatioChanged is being invoked every OnParameterSet(), which is causing the component to rerender, which then invokes OnParameterSet() again, and so on and so forth.

This change hides RatioChanged behind the parameter Ratio. Setting the Ratio property to a value will invoke its setter, which will check if to see if the value has changed before updating the local copy and invoking RatioChanged. This way, only when the value of Ratio has changed will the callback RatioChanged be invoked.

Please request any changes necessary.

Thanks, Dan

Chronostasys commented 3 years ago

Yes, you are right. Sorry for the late reply, I'm too busy last few weeks. The fix works very nice, thank you for your contribution.