Changing image dynamicly sometimes creates two croppers

17 views
Skip to first unread message

Jacob

unread,
Sep 20, 2010, 7:33:19 AM9/20/10
to javascript-image-cropper-ui
As the image I linked in the end of this post shows; there is two
croppers on top of the same image.

When I change the images' source I have to remove the cropper and set
it again with different ratio/minWidth/minHeight. Sometimes when I
change image two cropper tools appear on top of the image.

Only one of the tools can set cords and dimensions but the other one
still appears and can be tweeked as if that tool still is in use.

I have tried numeral ways but can't get it to work.

I save my class in a var called "cropClass", when I change the image I
use "cropClass.remove();" but that didn't to the trick. I then tried
all bunch of things including the code blow:

function setCrop(settings)
{
if(cropClass !== null)
{
cropClass.reset();
cropClass.remove();
cropClass = null;
$$('#activeCoords > input').each(function(elm)
{ elm.setValue('0'); });
}

cropClass = crop(settings);
}

Two cropper tools on the same image:
http://i51.tinypic.com/2zhfhok.png

David Spurr

unread,
Sep 20, 2010, 8:27:57 AM9/20/10
to javascript-image-cropper-ui
Hi Jacob,

Did you take a look at the dynamically changing image demo:
http://www.defusion.org.uk/demos/060519/cropper.php?demoType=dynamic&image=castle

Essentially that is doing the same as you but is all within a class.
In your example I'd add some debugging to ensure that it is actually
null and being removed as you expect it to be.

-D

Jacob

unread,
Sep 20, 2010, 8:37:20 AM9/20/10
to javascript-image-cropper-ui
Hi David,

Thank you for a fast reply.

Yes I have studied that page from top to bottom a couple of time but
with no luck. I'm thinking of doing a function which removes all
elements except the image to see if that helps.



On 20 Sep, 14:27, David Spurr <david.sp...@gmail.com> wrote:
> Hi Jacob,
>
> Did you take a look at the dynamically changing image demo:http://www.defusion.org.uk/demos/060519/cropper.php?demoType=dynamic&...

David Spurr

unread,
Sep 20, 2010, 8:42:02 AM9/20/10
to javascript-image-cropper-ui
Actually on reflection the example on the demo page never nulls out
the cropper, just removes/resets it as appropriate. Essentially if you
do as the demo is doing then I'm 100% sure it'll work.

-D

Jacob

unread,
Sep 20, 2010, 8:51:01 AM9/20/10
to javascript-image-cropper-ui
I really have tried that.

My users can set which ratio they would like to use (1:1, 3:2, 4:3 and
16:9) and also if they want the cropper to be vertical or horizontal -
further more they can turn the picture around (which reloads the
picture).

Maybe my problem has something to do with that I have to set minHeight/
minWidth/ratio/.. and that I change that everytime my users change
image.
Reply all
Reply to author
Forward
0 new messages