JCrop: Prevent de-selection?
Asked Answered
I

4

8

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?

Itinerant answered 27/1, 2012 at 15:26 Comment(0)
I
-1

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.

Itinerant answered 9/2, 2012 at 21:26 Comment(1)
The link is deadWohlert
S
23

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

Skinny answered 12/2, 2012 at 16:9 Comment(0)
O
1

allowSelect option is available now

Ollayos answered 15/12, 2013 at 16:8 Comment(0)
V
0

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

Vestal answered 22/11, 2015 at 21:17 Comment(0)
I
-1

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.

Itinerant answered 9/2, 2012 at 21:26 Comment(1)
The link is deadWohlert

© 2022 - 2024 — McMap. All rights reserved.