tapmodo / Jcrop

Jcrop - The Javascript Image Cropping Engine
https://jcrop.com
Other
4.31k stars 938 forks source link

Min Width/Height for selectable area #139

Closed dlaynes closed 10 years ago

dlaynes commented 10 years ago

Hi, I was wondering if Jcrop allows you to restrict the minimun size of the selectable area, or if you can control this using events. Thanks a lot for your response.

dlaynes commented 10 years ago

I solved this problem using events:

var options = {}; //some options
jcrop_api = jQuery.Jcrop('#crop-me', options);
//...
jcrop_api.setSelect([0,0,w,h]);
jcrop_api.setOptions({
        allowSelect: false,
        aspectRatio: page_max_width / page_max_height,
        onChange: function(coords){
          if(coords.w < page_max_width || coords.h < page_max_height){
            jcrop_api.setSelect([coords.x,coords.y,coords.x+page_max_width,coords.y+page_max_height]);
          }
        }
      });