Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

As on element animates in, animate another out

As one element slides in I need the other element to slide out. At the moment I have set it to fadeOut. This is the code I have so far:

$('#contact').click(function () {
    $('#contact-info').animate({
        width: 'toggle'
    });
    $('#work-menu').fadeOut('100');
});
$('#menu').click(function () {
    $('#work-menu').animate({
        width: 'toggle'
    });
    $('#contact-info').fadeOut('100');
});

DEMO

How can I change this code to make the opposite elements slide back as the other one slides into view?

like image 710
angela Avatar asked Nov 02 '22 14:11

angela


1 Answers

use 'hide'

$('#contact').click(function () {
    $('#contact-info').animate({
        width: 'toggle'
    });
    $('#work-menu').animate({
        width: 'hide'
    });
});
$('#menu').click(function () {
    $('#work-menu').animate({
        width: 'toggle'
    });
    $('#contact-info').animate({
        width: 'hide'
    });
});

DEMO

like image 90
Anton Avatar answered Nov 11 '22 14:11

Anton