Reputation: 21218
In my application I have a div that is hidden to 90%. The rest of the div is revealed if you click on the part you see. The div slides down 200px and when it's all down I want it to bounce a couple of times. Below is the code, but by some reason the bouncing doesn't work.
I would really appreciate if someone could help me out!
var boxDown = false;
$('#uploadContainer').click(function(){
if (boxDown === false) {
$(this).animate({
'marginTop': "+200px"
});
$(this).effect("bounce", { times:3 }, 300);
boxDown = true;
}
else {
$(this).animate({
'marginTop': "-=200px"
});
boxDown = false;
}
});
Upvotes: 1
Views: 1109
Reputation: 945
Not sure if this is the effect you desired, it's bouncing for me: http://jsfiddle.net/drAXv/
I'm guessing that you didn't implement the .ready() function?
Upvotes: 1
Reputation: 25165
It should work as expected holyredbeard...
Check out this jsFiddle that depicts your code. All works as supposed.
Maybe you're not loading jQuery UI?
Upvotes: 0
Reputation: 6045
Personally, I would use jQuery easing function: http://gsgd.co.uk/sandbox/jquery/easing/
look at the easeOutBounce
one
You use it like this:
$('#my-item').animate(
{
'margin-top': -110
}, 1000, 'easeOutBounce');
Upvotes: 1