简体   繁体   中英

How to add a bounce effect to a JS function

How would I add a "bounce" effect to this slide-in function;

$(window).load(function(){

$('.show').hover(function() {
$('.tool_hover').animate({
    'left':'190px'},
                        'slow');
},function() {
$('.tool_hover').animate({
    'left':'3000px'},
                        'slow');
});

});

so that when the "tool_hover" completes its slide in to 190px it bounces left to right before coming to a complete stop.

Add the jQuery easing plugin:

http://gsgd.co.uk/sandbox/jquery/easing/

Then add 'easeInOutBack' to your animation syntax. It looks like this:

$('.show').hover(function() {
    $('.tool_hover').animate({'left':'190px'}, {left:'easeOutBack'}, 'slow');
},function() {
    $('.tool_hover')$('.tool_hover').animate({'left':'3000px'}, {left:'easeOutBack'}, 'slow');
});

jQuery UI has bounce effect.

UI/Effects/Bounce

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM