Lock aspect ratio with checkbox or similar

2 views
Skip to first unread message

The User Is On Fire!

unread,
Jul 14, 2008, 7:30:28 PM7/14/08
to javascript-image-cropper-ui
Hey!

First, thanks for this extremely useful widget. Well done!

I would like to know if there's any way I could lock/unlock the aspect
ratio by triggering this behavior through a checkbox or similar.
The thing is most of the times I'd need to be locked to 1:1 but the
user should be able to deactivate this at will.

Is there any posibility to do this? How?

Thanks in advance!

Pablo

Dale Newfield

unread,
Jul 15, 2008, 5:05:14 PM7/15/08
to javascript-im...@googlegroups.com
The User Is On Fire! wrote:
> I would like to know if there's any way I could lock/unlock the aspect
> ratio by triggering this behavior through a checkbox or similar.

Yes--I've done something similar myself. Add an option on creation,
then inside the setAreaCoords function put something like the following:

if (this.squareCheckbox) {
square = square | this.squareCheckbox.checked;
}

You may have to add an onchange to the checkbox:

function toggleKeepSquare() {
var newKeepSquare =
document.getElementById("keepSquareCheckbox").checked;
cropper.setAreaCoords( cropper.areaCoords, newKeepSquare,
newKeepSquare, 1 );
cropper.selArea.show();
cropper.drawArea();
cropper.endCrop();
}


-Dale

The User Is On Fire!

unread,
Jul 16, 2008, 6:03:37 PM7/16/08
to javascript-image-cropper-ui
Dale! Thanks for your quick answer but I'm not a javascript/prototype
guru :(

Could you please explain the details or where i should modify code? I
really need this functionality.
Thanks in advance!

Pablo
Reply all
Reply to author
Forward
0 new messages