Daniel B.
Daniel B.

Reputation: 1680

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:

One potential solution would solve the above problems:

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?

Upvotes: 8

Views: 4924

Answers (4)

Peter Moses
Peter Moses

Reputation: 2137

I saw this on GitHub and it helps.

$('#cropbox').Jcrop({
    onSelect : updateCoords,
                bgColor : 'transparent',
                bgOpacity : .2,
                setSelect : [ 0, 0, 700, 300 ],
                minSize : [700, 300],
                allowSelect : false,
                onRelease : releaseCheck
                });
        });

function releaseCheck() {
    this.setOptions({ setSelect: [0,0,700,300] });
}

https://github.com/tapmodo/Jcrop/issues/5#issuecomment-1801926

Upvotes: 0

Viacheslav Gostiukhin
Viacheslav Gostiukhin

Reputation: 301

allowSelect option is available now

Upvotes: 1

dandamian
dandamian

Reputation: 276

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

Upvotes: 23

Daniel B.
Daniel B.

Reputation: 1680

As I wasn't able to find a feasible modification for jCrop to prevent de-selection, I went with the YUI ImageCropper instead, which ships with both of the necessary features.

Upvotes: -1

Related Questions