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 7840981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:59:24+00:00 2026-06-02T15:59:24+00:00

I am currently creating a scrolling slideshow from scratch, and have run into a

  • 0

I am currently creating a scrolling slideshow from scratch, and have run into a problem.

When I press the next button multiple times, the slides start to run together, how can I make sure the next slide waits until the current slide stops before the next one starts.

    var scrollAmount=910
    var image0Left=-scrollAmount;
    var image1Left=0;
    var image2Left=scrollAmount;
    var scrollSpeed0=2000;
    var scrollSpeed1=2000;
    var scrollSpeed2=2000;
    $(document).ready(function() {
        $("#left-arrow").click(showPreviousSlide);
        $("#right-arrow").click(showNextSlide);
    });

    function showPreviousSlide(){
        image0Left+=scrollAmount;
        if(image0Left > scrollAmount){
            image0Left=-scrollAmount;
            scrollSpeed0=0;
        }

        image1Left+=scrollAmount;
        if(image1Left > scrollAmount){
            image1Left=-scrollAmount;
            scrollSpeed1=0;
        }

        image2Left+=scrollAmount;
        if(image2Left > scrollAmount){
            image2Left=-scrollAmount;
            scrollSpeed2=0;
        }

        $("#slide0").animate({left: image0Left}, scrollSpeed0);
        scrollSpeed0=2000;
        $("#slide1").animate({left: image1Left}, scrollSpeed1);
        scrollSpeed1=2000;
        $("#slide2").animate({left: image2Left}, scrollSpeed2);
        scrollSpeed2=2000;
    }

    function showNextSlide() {
        image0Left-=scrollAmount;
        if(image0Left < -scrollAmount){
            image0Left=scrollAmount;
            scrollSpeed0=0;
        }

        image1Left-=scrollAmount;
        if(image1Left < -scrollAmount){
            image1Left=scrollAmount;
            scrollSpeed1=0;
        }

        image2Left-=scrollAmount;
        if(image2Left < -scrollAmount){
            image2Left=scrollAmount;
            scrollSpeed2=0;
        }


        $("#slide0").animate({left: image0Left}, scrollSpeed0);
        scrollSpeed0=2000;
        $("#slide1").animate({left: image1Left}, scrollSpeed1);
        scrollSpeed1=2000;
        $("#slide2").animate({left: image2Left}, scrollSpeed2);
        scrollSpeed2=2000;
    }

That is all of the controlling script code. Here is a link to the actual site. Site

There are three image slides that is moved each time the showPreviousSlide or showNextSlide is called. How can I make sure that one iteration of showPreviousSlide/showNextSlide function is finished moving my slides before it is called again? I removed my slideshow div overfill:hidden so that it’s easier to see what is happening on my slideshow.

Thank you for your help.

Morgan

  • 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-02T15:59:26+00:00Added an answer on June 2, 2026 at 3:59 pm

    You can pass completion callback to .animate() like this:

    animationCompleted = false;
    $("#slide0").animate({left: image0Left}, scrollSpeed0, function() {
        animationCompleted = true;
    });
    

    Then check the value of animationCompleted in your functions:

    function showPreviousSlide(){
        if (!animationCompleted) return;
        // ...
    }
    

    And check out the docs for additional information and examples.

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

Sidebar

Related Questions

im currently creating a graph for an app, using coreplot and have a problem
So I am currently creating a website and I have a problem. I have
I'm currently creating animation with xna. I have no problem to animate spritesheet when
I'm creating a 2d side scrolling game and have a question regarding the collision.
I am currently creating a script to synchronize users from our company's website onto
I am currently creating a console application which is reading from a folder which
I'm currently creating a stock management system that uses multiple warehouses (with sub locations)
I'm currently creating my own CMS and I have a hard question (I think
I'm currently creating some test cases with Selenium and I've come across a problem.
Im currently creating a uninstallation application which deletes the application folder. The problem is

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.