Agontuk / vue-cropperjs

A Vue wrapper component for cropperjs https://github.com/fengyuanchen/cropperjs
MIT License
932 stars 225 forks source link

Placing VueCropper inside Bootstrap Modal #25

Closed domi91c closed 6 years ago

domi91c commented 7 years ago

In a parent component, I'm using Jquery to open a modal containing VueCropper. VueCropper is initialized before I open the modal, and so it doesn't fit the size of the modal properly.

  openCropModal(file) {
       this.image = file.url;
       $('.js-crop-modal').modal('show');
  },

  <crop-modal :image="image"></crop-modal>

To use Cropper.js inside a modal, it must be initialized after the modal has opened. Is there a way I can do this with VueCropper?

Agontuk commented 7 years ago

If vue-cropper is inside a modal and it is initialized, it means the modal is already mounted, you're just making it visible by calling modal('show'). So modal must be initially unmounted and only mount when calling modal('show'), that way it'll work.

domi91c commented 7 years ago

Can you explain how I can set it up that way? I'm pretty new to Vue.

Thanks for the help by the way.

Agontuk commented 7 years ago

Just using conditional mounting should work, see example here Vue Modal Example. Also there are plenty vue specific modal libraries you can use.

Agontuk commented 6 years ago

Closing due to inactivity.