Question

so basically the problem is that Jcrop's onRelease is not working for me? Here is a part of the code

$('#target').Jcrop({
  aspectRatio: 9 / 16,
  minSize: [minCropWidth, minCropHeight ],
  onChange: updatePreview,
  onSelect: updatePreview,
  onRelease: cropIt
},function(){

...

function cropIt(){
    console.log("The onRelease function");
}

So, the "updatePreview" function works like a charm, but, the "cropIt" does nothing. Can't even get a console.log(); to show.

Any ideas?

Was it helpful?

Solution

It might be that you misunderstood the behaviour of the onRelease method?

Lets have a look this simplified fiddle, with the browsers console opened:

The image is loading fine and you can select a part of the image that you want to crop. Your console is logging a lot of

[Log] The updatePreview function (show, line 43)
[Log] The updatePreview function (show, line 43, x34)
[Log] The updatePreview function (show, line 43)
[Log] The updatePreview function (show, line 43)

updatePreview calls, since it is called whenever you change the selection.

Now you stop your selection, and probably expect onRelease to trigger. But this is not happening. Why?

onRelease triggers when you let go your selection, hence clicking anywhere on the image outside of your selection will trigger it.

[Log] The onRelease function (show, line 39)

onRelease means you cancel your selection, not to stop dragging your crop indicator.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top