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

Scale is null after uploading image with same dimensions as previous image #247

Open elanclarkson opened 2 years ago

elanclarkson commented 2 years ago

Hi there, thanks a lot for this plugin!

There is a bug where the scale property is null in the object returned bygetMetadata() after uploading an image that has the same dimensions as the previous image.

The reason for this is because the scaleRatio property is set automatically via Vue watchers when the width and height change, however when changing images, scaleRatio gets initialised back to null within the _initialize() method. This is fine if the width and height change because the watchers are triggered again, but if the width and height are the same then a change is never triggered and scaleRatio remains null.

I have gotten around this by not setting scaleRatio back to null in the _initialize() method. This works well in my case but I am unsure if it is the best approach to take generally speaking. Happy to submit a PR if you're fine with it though.