Jump to content

Sliding a div in while sliding a div out, on toggle


KeithF

Recommended Posts

Hello, i am trying to set up a couple of icons that when clicked slide a div on and another off screen.

Like seen here http://www.vogue.co.uk/spy/celebrity-photos/2014/02/04/david-bailey-exhibition-opening when clicking on the men and article icons to the left.

 

This is what i have: http://www.keithfrenchdesigns.com/RunwayMag/index.html 

 

My JS:

 var boxes = $('ul.topLevelNavigation');
   $(document).ready(function() {
    $('.button').click(function(e) {
        e.preventDefault();
        var box = $($(this).attr('href'));
        if (!box.hasClass("topLevelNavigation")) {
            var current = $('ul.topLevelNavigation');
            current.stop().animate({left: '-25%',}, 500 ).removeClass('topLevelNavigation');
            box.stop().animate({left: '25%',}, 500 ).addClass('topLevelNavigation');
        }
	});
	});

As you can see i get one partially on screen, but then when i start toggling the icons things began to slide on and off. Another issue is, the first navigation is not even showing correctly on load of the page..

 

I'm new to JavaScript, so i've gotten a little confused on why it's acting the way it is. Thanks in advance for any help.

Edited by KeithF
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.