You're repeating a bunch of code here. It'd be better to assign a
variable for the img at the beginning of the function.

function()
{
        var img = $(this).find('img');
        
        var value = (direction =='top' || direction=='bottom')
                ? img.outerHeight() * -1
                : img.outerWidth() * -1);
                
                img.stop().animate(
                        {direction: value},
                        {duration: 500, easing: 'easeOutBounce'}
                );
}

HOWEVER, the {direction: value} doesn't make any sense. That should
contain CSS properties that you wish to animate the element towards.
What is it you're try to do?

Actually, which element are you assigning this handler to? It's not
the img itself, is it?

Also, is it possible that the img could have more than a single class
assigned? That could bugger things up, i think. Better to use
hasClass() in that csae.


On Sun, Jan 24, 2010 at 7:10 PM, kevin <[email protected]> wrote:
> Hi, I'm writing this script and apparently the animate method wouldnt
> interpret the variable I pass in the properties section:
>
>
> //it's hover event, and this is the mouseover
> function () {
>                direction = $(this).find('img').attr('class');  //should be 
> either
> top, bottom, left or right
>                value = ((direction =='top' || direction=='bottom') ? 
> $(this).find
> ('img').outerHeight() * -1 : $(this).find('img').outerWidth() * -1);
>
>                $(this).find('img').stop().animate({direction: value} 
> ,{duration:
> 500, easing: 'easeOutBounce'});
> }
>
> I have tested the content of variable, and there are 100% working, my
> final verdict is, the animate method doesn't read the variable
> "direction" properly. Anyone has any ideas to get around with this
> problem?
>
> Thanks
>

Reply via email to