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

On resizing startX and Y reset #72

Closed FraukeVdz closed 6 years ago

FraukeVdz commented 6 years ago

Hey

When I change the width and height of the widget, the position of the image is reset to the middle. But when the widget is resized, I want the image to hold his original position (chosen by the user).

I can't seem to find the place in the code where this happens.

Can you help me?

Thanks!

zhanziyang commented 6 years ago

This is expected if you set prevent-white-space to true. Code is at: https://github.com/zhanziyang/vue-croppa/blob/5e661062b34063967995ee5c201c8ee8ad20c600/src/cropper.vue#L1139-L1149 As you can see, if preventWhiteSpace is true, imageSet will be false, then in the this._placeImage() function, the image position will be reset.

If you are curious why it should work this way, please see more in this issue.

mcordoba commented 6 years ago

Why not zoom in the image and avoid the reset even when prevent-white-space is set to true?

If you select an image smaller than the viewport it can be zoomed in to fill the viewport.

I think is a more desirable behaviour than reset coordinates.

Im trying to reproduce behaviour like the main demo in this page http://guillotine.js.org/ but it has been imposible so far.