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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:41:39+00:00 2026-05-12T05:41:39+00:00

I have a trivial little game I wrote in javascript that creates a wave

  • 0

I have a trivial little game I wrote in javascript that creates a wave from where you click. I figured out two ways to make the “wave” move across the screen:

  1. by calling jQuery.animate() with increasingly large times. demo
  2. by recursvely calling setTimeout. demo

The problem I have is that I want the behavior of 2 (columns all grow at the same speed with an offset timing) but with the action of 1 (subsequent clicking compounds the “waves” formed).

Right now on the second demo, if you click again before the “wave” is finished, it immediately clears the setTimeouts and starts them all over again. I want to be able to stack them like in the first example.

You can view the source of either of those pages to see the code (methods are getMouseXYUp and getMouseXYDown).

the basic gist of what i am doing in the second demo is found in these two functions:

function getMouseXYUp(e) {
            $("body").die('mousemove');

            h = (document.height - e.pageY + 17);
                left = id-1;
                right = id+1;
            setTimeout("moveleft()", 100);
            setTimeout("moveright()", 100);

            return true
        }

function moveleft(){
        if (left >= 0){
            $("#div"+left).animate({'height': h}, 400);
            left--;
            setTimeout("moveleft()", 50);
        }
    }
  • 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-05-12T05:41:39+00:00Added an answer on May 12, 2026 at 5:41 am

    The problem is that you’re resetting the variables “left” and “right” as soon as the second mouse click happens. Is this any closer to what you’re looking for?

        function getMouseXYUp(e) {
            $("body").die('mousemove');
    
            var h = (document.height - e.pageY + 17);
            var left = id-1;
            var right = id+1;
            setTimeout(function() { moveleft(left, h); }, 100);
            setTimeout(function() { moveright(right, h); }, 100);
    
            return true;
        }
    
        ...
    
        function moveleft(left, h) {
            if (left >= 0){
                $("#div"+left).animate({'height': h}, 400);
                left--;
                setTimeout(function() { moveleft(left, h); }, 50);
            }
        }
    
        function moveright(right, h) {
            if (right < divs){
                $("#div"+right).animate({'height': h}, 400);
                right++;
                setTimeout(function () { moveright(right, h); }, 50);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 239k
  • Answers 239k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer class Directions: up = 0 down = 1 left =… May 13, 2026 at 6:55 am
  • Editorial Team
    Editorial Team added an answer The implementation details of HashMap can and do change. Most… May 13, 2026 at 6:55 am
  • Editorial Team
    Editorial Team added an answer I see 3 ways to go: The most obvious and… May 13, 2026 at 6:55 am

Related Questions

I'm creating a game with points for doing little things, so I have a
Any SQLite database on the iPhone is simply a file bundled with the application.
I have a little problem that perhaps you can help me with. I try
So I think I'm going to get buried for asking such a trivial question

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.