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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:45:08+00:00 2026-06-02T17:45:08+00:00

I have a #ball that when clicked uses jquery animate to move down 210px

  • 0

I have a #ball that when clicked uses jquery animate to move down 210px using this code:

 $('#ball').click(function() {
    $(this).animate({
        top: '+=210px'
    }, 500);
    setTimeout(crack, 400);
});​

currently Im using Timeout to trigger the next function which is “crack”.
Instead I want to track the movement of #ball and when its css top = 210px I want to trigger the function crack(), how can I do this?

I saw in a somewhat similar post that the Step function might be what I’m looking for, but I am not sure how to approach that solution based on the info provided at http://api.jquery.com/animate/

Look at Demo: http://jsfiddle.net/EnigmaMaster/hbvev/4/

  • 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-02T17:45:09+00:00Added an answer on June 2, 2026 at 5:45 pm

    I am not sure why you want to use a tracker if you know that the ball will reach the box in 210px.

    If you want to get rid of setTimeout, then use the .animate callback function which will be called when the ball reaches the box.

    $('#ball').click(function() {
        $(this).animate({
            top: '+=210px'
        }, 500, crack); //<== crack will be called after ball animation
    });​
    

    DEMO

    Incase if you want to call crack when the ball touches the box and still continue the movement of box then you can execute it 2 steps like below,

    $('#ball').click(function() {
        $(this).animate({
            top: '+=180px'
        }, 400, function() {
            crack();
            $(this).animate({
                top: '+=30px'
            }, 100);            
        });
    });
    

    Also check this version for fun in slow motion http://jsfiddle.net/skram/hbvev/8/

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

Sidebar

Related Questions

I have to code an object detector (in this case, a ball) using OpenCV.
I have a page that uses jQuery.animate to scroll the body/html of the document,
I have this quickBox2d code to add a cricle to the stage: var ball:QuickObject
I have a ball based on a component and I've thought that using the
I have a basic game function that drops a ball every 500 milliseconds (with
The problem is that this ball after it is dragged and exited click, it
I have a ball (a dynamic body in the shape of a circle) that
At the moment am using JOGL for a ball detection program I have been
I have a game that one player X wants to pass a ball to
I have got a ball which bounces of walls. This bounce is simple, i

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.