I could not get this to work and found your question in finding a solution on my own.
I am using a preview demo (tutorial3) in Jcrop v0.9.9.
Changed jQuery(function($){ to jQuery(window).load(function(){
And added the setSelect: [ 0, 40, 312, 244 ] option setSelect: [ 0, 40, 312, 244 ]
And it does not update the preview at boot.
The workaround I found is to use api animateTo , as well as setSelect (or your own, if you like the animation, the speed of which you can change using the swingSpeed option)
I made changes to my code
jQuery(function($){ // Create variables (in this scope) to hold the API and image size var jcrop_api, boundx, boundy; $('#target').Jcrop({ onChange: updatePreview, onSelect: updatePreview, setSelect: [ 0, 0, selectWidth, selectHeight ], aspectRatio: 1 },function(){ // Use the API to get the real image size var bounds = this.getBounds(); boundx = bounds[0]; boundy = bounds[1]; // Store the API in the jcrop_api variable jcrop_api = this; jcrop_api.animateTo([ 0, 0, selectWidth, selectHeight ]); }); function updatePreview(c) { if (parseInt(cw) > 0) { var rx = 100 / cw; var ry = 100 / ch; $('#preview').css({ width: Math.round(rx * boundx) + 'px', height: Math.round(ry * boundy) + 'px', marginLeft: '-' + Math.round(rx * cx) + 'px', marginTop: '-' + Math.round(ry * cy) + 'px' }); } }; });
source share