Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JCrop: Prevent de-selection?

I'm currently setting up an image-upload cropping sequence.

The application requires an enforced minimum size, however this results in awkward JCrop behavior:

  • Clicking without dragging produces nothing.
  • Clicking & slightly dragging produces instantly a selection of the minimum height.

One potential solution would solve the above problems:

  • Interface opens with a default selection.
  • The selection cannot be de-selected.

JCrop has built-in functionality for a default selection, however I haven't yet identified a built-in configuration / behavior to prevent deselection.

Attempts so far -

I've tried this route

$.Jcrop.defaults.onRelease = function(e) {
     e.preventDefault();
     e.stopPropagation();
}

I've also tried modifying the plugin's source in several places, in order to short-circuit the functions which (perhaps) carry out the de-selection, by returning at the opening of these function definitions:

doneSelect Selection.release Selection.done

...without the desired result.

Any tips?

like image 629
Daniel B. Avatar asked Jan 27 '12 15:01

Daniel B.


1 Answers

Set allowSelect: false, for details check: https://github.com/tapmodo/Jcrop/issues/5#issuecomment-1801926.

like image 70
dandamian Avatar answered Oct 28 '22 10:10

dandamian