Hello, I'm trying to figure out how to fixed the selection box size under JCrop, he mentions how to set an initial selection area but not how to make it fixed size. Does anybody knows how could I make it fixed. Thanks in advance.
+3
A:
Using this example you should be able to keep the size fixed.
$(function(){
$('#jcrop_target').Jcrop({
onChange: function(){ $(this).setSelect([x, y, x2, y2]); }
});
});
muhuk
2008-12-06 14:08:05
That seems like a fairly hackish way of setting a fixed size crop area by forcing a resize after the change event has finished firing.
cballou
2010-01-20 15:35:10
+3
A:
You can use the aspectRatio option. This will force a square selection
$(function(){ $('#cropbox').Jcrop({ aspectRatio: 1 });
});
Or aspectRatio: 16/9 would make it wide sreeen :-)
The Disintegrator
2009-07-31 05:13:40
Then he should use something likeminSize: [ 100, 150],maxSize: [ 100, 150]http://deepliquid.com/content/Jcrop_Manual.htmlSpecifying the same dimensions for min and max
The Disintegrator
2010-01-21 05:11:16
+3
A:
You are basically looking for the API section. Having extensively used this plugin myself, I know exactly what you're looking for:
var api;
var cropWidth = 100;
var cropHeight = 100;
$(window).load(function() {
// set default options
var opt = {};
// if height and width must be exact, dont allow resizing
opt.allowResize = false;
opt.allowSelect = false;
// initialize jcrop
api = $.Jcrop('#objectId', opt);
// set the selection area [left, top, width, height]
api.animateTo([0,0,cropWidth,cropHeight]);
// you can also set selection area without the fancy animation
api.setSelect([0,0,cropWidth,cropHeight]);
});
cballou
2010-01-20 15:25:50
+1
A:
you can set the aspectRatio as decimal value
$('#jcrop_target').Jcrop({
setSelect: [0,0,150,100],
aspectRatio: 150/100
});
tuffkid
2010-02-08 21:32:27