Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8218683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:53:08+00:00 2026-06-07T12:53:08+00:00

I’m trying to create this sliding effect but the only problem I’m having is

  • 0

I’m trying to create this sliding effect but the only problem I’m having is queuing.

$(this).animate({'left' : '0%'}, randTime, function() {
    $(this).animate({'boxShadow' : 'none'});
    setTimeout(function() {
        $container.children('.slice').addClass('noshadow');
        $('body > div:not(#'+container+') .slice').each(function() {
            restartAnimation($(this));
        });             
    $container.children('.content').fadeIn();   
    }, (aLength+100));
});

The container variable above is the current container. I did :not(container) so the current container would continue animating. This is all in a function that has two attributes, the ID of the container element and the way the animation is going to run (just keywords run through if statements). Then I will have a menu which activates the animations like this:

if($(this).attr('name') == 'home') {

    animation('home', 'top');

}
else if { .....

The restart animation function simply restarts all other animating elements to their original positions so they can be run again. Now, the problem is, there is delay until the restart function runs, so if you click two menu items within the delay time you end up with the restart function running and then everything gets quite confused.

I need a way to restart the animation back to its original position so it’s ready to run again, but not interfere and restart other animating elements. Otherwise we end up with a huge mess. I’ve set up a quick jsFiddle so you can try out the effect. The code is a little messy at the moment, I was planning on tidying everything up once I finished, but this queuing problem has really got me stuck. http://jsfiddle.net/qe7dj/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:53:10+00:00Added an answer on June 7, 2026 at 12:53 pm

    One way to deal with this would be to not allow another animation to start until the first animation is finished.

    There are probably a few ways to do this, but the one that comes to mind is to create a global function queue object (I’ll give an explanation and code below).

    You’ll need a global variable to keep track of how many slides are currently animating.

    var animationsRunning = 0;
    

    Every time a slide animation starts, increment the above variable. When a slide animation ends, decrement it.

    Now, before starting a whole new animation (of multiple slides), check that variable. If slides are currently animating, add the animation function to the global function queue. If not, go ahead and run the animation like normal.

    if ($(this).attr('name') == 'home') {
        if (animationsRunning < 1) {
            animation('home', 'top');
        }
        else {
            funqueue.push(wrapFunction(animation, this, ['home', 'top']));
        }
    }
    else if ($(this).attr('name') == 'about') {
        if (animationsRunning < 1) {
            animation('about', 'left');
        }
        else {
            funqueue.push(wrapFunction(animation, this, ['about', 'left']));
        }
    }
    
    else if ($(this).attr('name') == 'services') {
        if (animationsRunning < 1) {
            animation('services', 'hslide');
        }
        else {
            funqueue.push(wrapFunction(animation, this, ['services', 'hslide']));
        }
    }
    

    Every time all slides finish animating, check if there are any items in the global function queue. If there are, execute the first one.

    if (animationsRunning < 1 && funqueue.length > 0) {
        (funqueue.shift())();
    }
    

    The code pertaining to the function queue is shown below:

    // Function wrapping code.
    // fn - reference to function.
    // context - what you want "this" to be.
    // params - array of parameters to pass to function.
    var wrapFunction = function(fn, context, params) {
        return function() {
            fn.apply(context, params);
        };
    };
    
    // Global function queue
    var funqueue = [];
    

    The Stack Overflow question here has a very good explanation of the global function queue concept, so I won’t explain that in detail here.

    A working jsfiddle example can be found here.

    EDIT:

    You may want to prevent a build up of waiting animations – if this is the case you can simply clear the function queue before adding the latest item. Obviously you don’t actually need a queue in this case, but I’ve left it like that to be compatible with the first solution.

    An updated jsFiddle is located here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to construct a data frame in an Rcpp function, but when I
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.