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

  • Home
  • SEARCH
  • 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 6718749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:00:30+00:00 2026-05-26T09:00:30+00:00

I am using jsAnim for some simple animations . http://jsanim.com/ I have created a

  • 0

I am using jsAnim for some simple animations .

http://jsanim.com/

I have created a simple javascript function –

<script type="text/javascript">
var man = new jsAnimManager(); 

function animation1() {
    shroom = document.getElementById("mushroom2");

    man.registerPosition("mushroom2");

    var monster =  $("#mushroom2");
var offset = monster.offset();
var l=offset.left;
var r= offset.top;


    shroom.setPosition(l,r);

    var anim = man.createAnimObject("mushroom2");

    anim.add({property: Prop.position, to: new Pos(l+100,r+400), 
           duration: 1000,ease:jsAnimEase.parabolicNeg });
}

</script>

I have similarly defined another animation2() function .

The animation works well independently .
However I am trying to loop this animation inside a for loop.

for( var i=1, l=data.length; i < 6 ; i++) 
            {

                  if  ((i==1 )||(i==3)) animation1(); else animation2();


            }

But what I observe is that the animation happens only for i=5 ( i.e .. after the loop stops executing ) . There is no animation for i = 1-4 .

Is this some threading issue ? Do I need to use some form of threads or sleeper or something ?

Please help .

I wish to make the object take a few different paths in stages .

  • 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-26T09:00:31+00:00Added an answer on May 26, 2026 at 9:00 am

    All of the animation functions are being executed virtually instantaneously. Because the jsanim library doesn’t have queue functionality, the only animation you will see in this case is the last one (because each time the next animation is executed, the last one is aborted).

    But it does have an onComplete callback handler, so a queue is easy enough to implement. You need a queue array that is visible to all functions:

    var animationQueue = [];
    

    Then change your for loop to add the functions to the queue instead of executing them:

    for( var i=1; i<6; i++)  {
        if  (i%2==1)    //if i is odd number
            animationQueue .push(animation1); 
        else            //else i is even number
            animationQueue .push(animation2); 
    }
    nextAnimation();
    

    Also notice that I used i%2==1. I am assuming you want odd numbers here when you say if(i==1 || i==3). The nextAnimation() function could look something like this:

    function nextAnimation() {
        if(animationQueue.length) 
            animationQueue.shift()();
    }
    

    And lastly, you need to add the onComplete option in your call to the animation:

    anim.add({
        property: Prop.position,
        to: new Pos(l+100,r+400),
        duration: 1000,
        ease:jsAnimEase.parabolicNeg,
        onComplete: nextAnimation
    });
    

    Hope that gets you onto the right track!

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

Sidebar

Related Questions

Using Google Maps InfoBox - http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html Currently the map will scroll - pan control
Using the http://www.ifans.com/forums/showthread.php?t=132024 post from another question i am allowing the user to enter
Using online interfaces to a version control system is a nice way to have
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using the Cocoa Framework, how can I add bullets and numbering to text?
Using a Microsoft version of SQL, here's my simple query. If I query a
Using Lightbox for a photo gallery and would like to initiate the function by
Using the following as an example (with $db being a previously created database connection
Using SolrNet for querying & faceting. I have a combination of int, tdate and

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.