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

The Archive Base Latest Questions

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

I have an animation that is mostly working with jQuery and CoffeeScript. I have

  • 0

I have an animation that is mostly working with jQuery and CoffeeScript.

I have come a problem though that I can’t quite figure out.

class Cow
  move_head: (x, y)=>
    stander.animate({
left: 10,
  },{
    complete: @move_feet(x, y)
  });

  move_feet: (x, y)=>
    stander.animate({
left: 10,
  },{
    complete: @mover_in_test
  });

The problem is with complete: @move_feet(x, y). When there are no arguments, complete: @move_feet the code works fine and @move_feet is called when the move_head animation is completed. However, with complete: @move_feet(x, y), @move_feet(x, y) is called the moment move_head(x, y) is called.

I looked to what the CoffeeScript was compiling to, which is

in the complete: @move_feet(x, y) case to complete: this.move_feet(x, y) and
in the complete: @move_feet case to complete: this.move_feet.

Thus, I think it is calling complete: this.move_feet(x, y) as soon as it parses the code. However, how do I get it to delay this execution of the code until the proper time?

  • 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-30T06:39:43+00:00Added an answer on May 30, 2026 at 6:39 am

    Just make another anonymous function:

    complete: => @move_feet(x, y)
    

    Here are a couple of samples. First, something like your example:

    class Sample
      constructor: (@x, @y) ->
    
      do_later: =>
        later = => @do_alert(@x, @y)
        setTimeout(later, 2000)
    
      do_alert: (a, b) =>
        alert([a, b])
    
    a = new Sample(33, 44)
    a.do_later()
    

    You don’t need classes for this, of course:

    later = -> alert("hello")
    setTimeout(later, 1000)
    

    Note that if you want this to be preserved (e.g. inside a class), you need to use =>, otherwise -> will be OK. Basically, here later is an anonymous function that when called will run it’s body (alert("hello") in the above case). setTimeout(later, 1000) will effectively do later() in 1000ms.

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

Sidebar

Related Questions

I have created a jQuery animation that can be seen by clicking the Preview
I have a jQuery animation that positively refuses to loop. It will play through
I have a jQuery animation that animates the 'scrollLeft' on a container to produce
I have a storyboard animation that fades a control out of view using the
i have an animation that starts out as a plain back ground. when the
I have what I thought was a relatively easy Ajax/animation that I'm adding to
I have an animation on a partially hidden div container that will execute when
I have a Flex App that allows you to dynamically build an animation. It
I have a UIImageView object that when clicked it will play a animation, I
I have a UIImageView that is displaying a series of pictures as an animation.

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.