-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
minCropBoxWidth & minCropBoxHeight does not take in account scaling #31
Comments
The |
To make it relative to the image without modifying the plugin, try something like this: var cropper;
var buildCropper = function() {
cropper = new Cropper(image, {
aspectRatio: 1 / 1,
minCropBoxHeight: 250,
minCropBoxWidth: 250,
movable: false,
scalable:false,
zoomable:false,
crop: function(data) {
image.setAttribute('data-x', data.x);
image.setAttribute('data-width', data.width);
image.setAttribute('data-height', data.height);
image.setAttribute('data-y', data.y);
}
});
var scaledCropBox = {
x: (parseFloat(getComputedStyle(cropper.canvas)['width']) / image.width) * 250,
y: (parseFloat(getComputedStyle(cropper.canvas)['height']) / image.height) * 250
}
cropper.options.minCropBoxWidth = scaledCropBox.x;
cropper.options.minCropBoxHeight = scaledCropBox.y;
cropper.build();
}
buildCropper();
var resizeTimeout;
window.onresize = function(){
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function() {
cropper.destroy();
buildCropper();
}, 100);
}; It's not optimal as it requires building the cropper instance twice, however it seems to be accurate and it works. In this case, I destroy and rebuild the cropper when the window is resized, meaning the cropping process set by the user will reset. |
absoluteCropBoxWidth = cropBoxData.width * (canvasData.width / canvasData.naturalWidth); |
What does "relative to the page" even mean in this context? If it's relative to the "page," why does scaling affect it? In what use case is the current behavior desirable? This feels like an issue that should not have been closed. |
@Busata Did you resolve this? Having the same concerns |
No, but think I just used another library :)
…On Wed, 12 Sep 2018 at 13:24, Mathias Nilsson ***@***.***> wrote:
@Busata <https://github.com/Busata> Did you resolve this? Having the same
concerns
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#31 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA1w3f2uLzfLRjLqhkG4-IEdaBq-2PkBks5uaO7ggaJpZM4HUftg>
.
|
When setting these two options, they seem to apply to the box size itself, not taking into account the image. Is this intended? Is it possible to restrict the cropping to a certain px, relative to the image?
The text was updated successfully, but these errors were encountered: