fengyuanchen / cropper

⚠️ [Deprecated] No longer maintained, please use https://github.com/fengyuanchen/jquery-cropper
MIT License
7.75k stars 1.74k forks source link

Adapt cropper area/img container to mobile resolutions #960

Closed BugDroid-Duarte closed 6 years ago

BugDroid-Duarte commented 6 years ago

Hello,

I sucessfully implement the cropper on my project but its not usable on mobile because the image is always bigger than the modal container (the cropper is inside a modal) andi cannot see all the image on mobile res.

I tried several combinations of max-widths, widths, on cantainers, on the img tag but cannot do it, i have set:

minContainerWidth: 568, minContainerHeight: 320

If i remove it, it works but then its too small on mobile and super small on PC

Heres my setup:

reader.onloadend = function () { $cropperModal.find('.image-container').html($img); $img.attr('src', reader.result); $img.cropper({ preview: '.image-preview', aspectRatio: 16 / 11, autoCropArea: 1, movable: false, cropBoxResizable: true, minContainerWidth: 568, minContainerHeight: 320 }); };

MODAL:

var modalTemplate = '' + '

' + '
' + '';

i want to set like a max size, and that the cropper stuff adapts to the screen, sorry to ask here but i am trying for hours and still couldnt do it.

Thanks

fengyuanchen commented 6 years ago

You need a responsive container: https://github.com/fengyuanchen/cropper/blob/master/examples/responsive-container.html