Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep Image Position Center After Rotate #307

Open
Rupato opened this issue Aug 24, 2020 · 0 comments
Open

Keep Image Position Center After Rotate #307

Rupato opened this issue Aug 24, 2020 · 0 comments

Comments

@Rupato
Copy link

Rupato commented Aug 24, 2020

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

                                <!-- This range input controls zoom -->
                                <!-- You can add additional elements here, e.g. the image icons -->
                                <!-- This is where user selects new image -->
                                <input type="file" class="noscroll-img-file cropit-image-input desktop-cropit hide" name="content-box-desktop-file" accept="image/jpeg, image/jpg, image/png, image/gif" />

                                <input type="range" class="cropit-image-zoom-input hide" />
                                <!-- The cropit- classes above are needed
    so cropit can identify these elements -->
                                <button class="rotate-ccw desktop-buttons-ccw hide">Rotate counterclockwise</button>
                                <button class="rotate-cw desktop-buttons-cw hide">Rotate clockwise</button>
                                <span class="hide rotationValue"></span>
                                <span class="hide stroredTrans"></span>
                            </div>

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();
}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant