scottcheng / cropit

A "customizable crop and zoom" jQuery plugin.
http://scottcheng.github.io/cropit/
MIT License
874 stars 307 forks source link

Keep Image Position Center After Rotate #307

Open Rupato opened 3 years ago

Rupato commented 3 years ago

Currently On rotating the image 90deg the image touches the right border 180deg it touches the bottom border and at 270deg it touches the left border Wanted the image position to be in the center after rotation managed to get the image in the center by calculating and resetting the translate value on rotate but the data(data64..) required to export the image on the cropit preview does not change.

` HTML

JS function initialiseCropIT() { var $imageCropper = $('#image-cropper-desktop').cropit({ //imageBackground: true, minZoom: 'fit', maxZoom: '5', smallImage: 'allow', imageBackground: false, allowDragNDrop: true, fitWidth: true, fitHeight: true, onImageLoaded: function () { cropD = "false"; rotateD = 0; zoomD = 0; $('#image-cropper-desktop').find('.desktop-cropit-preview').css('background', 'none'); }, onZoomChange: function () { zoomD = $('#image-cropper-desktop').find('.cropit-image-zoom-input').val(); } }); $imageCropper.cropit(); } `