0

Following is my PLNKR CODE.

Flow -

1) Click on any of the four images(pink, green, yellow, blue) they get loaded into the red div.

2) Drag the image and click on "Apply Crop" button.

But now I want to remove the cropping option so I clicked on "Remove Crop" button.

Code on Remove Crop button click -

$("#removeCrop").on("click", function(){
    jcrop_api.release();
});

Now the problem is though the cropping release from the div but now the image is no more draggable even though if I clicked on lower images from the tray and also the mouse pointer gets changed.

Let me know what I am doing wrong with the code. I tried to re instantiate the code "draggable" code in $("#removeCrop").on("click" but no luck. I created the whole on my own but from here I am unable to guess what I am doing wrong.

NOTE- Images are little heavy so it would be better to download the plnkr and replace images with some static images to have a better idea.

EDIT- I taken out some jQuery events from selImg event but no luck. Recent script - Changed Script

Trialcoder
  • 5,816
  • 9
  • 44
  • 66

1 Answers1

1

After doing the crop, your

<img id="inner" class="ui-draggable ui-draggable-handle" ...>

will change to

<img id="inner" ...>

and the classes ui-draggable ui-draggable-handle are removed. So the draggable will not work.

Also after adding the classes to your inner again, the jcrop-tracker is in front of your inner. So actually you can't click your inner component.

EDIT:

One dirty solution could be to hide the jcrop-tracker after your release:

$( ".jcrop-tracker" ).hide();

And then showing it in the Apply crop click event:

$( ".jcrop-holder div" ).show();
$( ".jcrop-holder div" ).css('opacity', 0.6);
$( "#wrapper" ).css('opacity', 1);
$( "#content" ).css('opacity', 1);

Here is the edited code: Edited Code

Raein Hashemi
  • 3,346
  • 4
  • 22
  • 33
  • So how do I fix it ? any help ? – Trialcoder Nov 10 '14 at 09:03
  • Just as a suggestion.. is there a way to know about the co ordinates of the image as how much it moved likewise, as I need to crop it at server end..any hint – Trialcoder Nov 10 '14 at 11:43
  • 1
    There's a `left` and `top` attribute in `style` which has the pixel results of your current picture position (but from bottom right which is (0,0)). You can access it like this: $("#inner").css("left"); – Raein Hashemi Nov 10 '14 at 12:02