advanced-cropper / vue-advanced-cropper

The advanced vue cropper library that gives you opportunity to create your own croppers suited for any website design
https://advanced-cropper.github.io/vue-advanced-cropper/
Other
930 stars 128 forks source link

Canvas does not update when image source changes #244

Closed Awatatah closed 11 months ago

Awatatah commented 11 months ago

Hello I am using version 1.11.6 and I came across an issue where if I use the following code:

<Cropper
    class="cropper"
    :src="imgSrc"
    :stencil-props="{
      aspectRatio: setAspectRatio(),
    }"
    @change="setNewCoords"
    imageRestriction="fit-area"
/>

and once mounted it works great but if the value of imgSrc changes, the cropper canvas does not update with the new image.

Is there something I need to do like call a function to reinitialize the Cropper? I'm a little stuck on this.

Norserium commented 11 months ago

@Awatatah, could you reproduce your issue in the codesandbox?

Awatatah commented 11 months ago

@Norserium I found the issue. I was using the cropper in a modal component that has props (which is how imgSrc is set) but when the value of the object changed in the parent, the prop did not reflect. I resolved this issue