views:

8347

answers:

3

Hi there,

i have a simple jquery animtion using fadein and it works but once faded in ... i wish to MOVE using TOP property 30 pixels upwards.. but slowly..

this is what i have so far.

$('#Friends').fadeIn("slow");

Any ideas?

I have both jquery and jquery UI loaded...

+3  A: 

Use jquery animate and give it a long duration say 2000

$("#Friends").animate({ 
        top: "-=30px",
      }, duration );

The -= means that the animation will be relative to the current top position.

Nadia Alramli
no it doesn't seem to work.. I have the following.. (tried top also ) $("#Friends").animate({ 'margin-top': "-=100px" }, "slow");reason is that my code is like this <div id="Friends" style="width: 133px; margin-left: 19px; margin-top: -30px; background-image: url(content/images/friends.png);
mark smith
this is an old prototype i was using... but wish to change to jquery..the prototype worked.var friends= document.getElementById('Friends');new Effect.Move(friends, { duration: 0.6, x: 0, y: -100, mode: 'relative' });
mark smith
fixed .. its because i didn't have relative set as position
mark smith
+2  A: 

You can animate it after the fadeIn completes using the callback as shown below:

$("#Friends").fadeIn('slow',function(){
  $(this).animate({'top': '-=30px'},'slow');
});
ichiban
A: 

Thanks Mark! Position relative did the trick :)

Jim