rayantony / jcrop

Automatically exported from code.google.com/p/jcrop
0 stars 0 forks source link

setImage doesn't stop animation by animateTo #80

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create a Jcrop instance
2. use animateTo to set the selection rectangle
3. before the animation is finished use setImage to change the image

What is the expected output? What do you see instead?
I expect the selection to be released, which is what happens if I call setImage 
while the selection is not animating. Instead, after the image changes, the 
handles reappear and continue to animate toward the original "animateTo" 
location.

What version of the product are you using? On what operating system?
using 
jquery.Jcrop.js v0.9.10

in mozilla firefox, but upon inspecting the code, it doesn't seem to be browser 
specific.

Please provide any additional information below.

I was able to fix this by modifying queueAnimator() in animateTo() to save the 
handle from window.setTimeout using the $.data() interface. then I added a call 
to window.clearTimeout in setImage()

It wasn't necessary for my purposes, so I left it out, but one would probably 
have to add this to the other functions that set the coordinates, including 
animateTo. But I didn't even test these cases, so I don't know if the bug shows 
up.

Original issue reported on code.google.com by shadowd...@gmail.com on 28 Aug 2012 at 11:07

GoogleCodeExporter commented 9 years ago
Ok... the fix I mentioned didn'T always work... so I created a closure for the 
animation percent and set it to 100%

function cancelAnimation()
    {
        var mine=$origimg.data("pcent");
        if (typeof(mine)=="function")
        {
            mine();
            window.setTimeout(cancelAnimation, options.animationDelay);
        }
    }

in animateTo:  $origimg.data("pcent",function(){pcent=100;});

and in the animator a call to removeData right before calling the callback

Original comment by shadowd...@gmail.com on 30 Aug 2012 at 10:01