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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:36:51+00:00 2026-06-13T19:36:51+00:00

I have this code where I have a made a character using 20 paths

  • 0

I have this code where I have a made a character using 20 paths and put it into a set.
Now when I animate the set, the first transformation runs smoothly, the second animation stutters, the third animation doesn’t happen as it should and the 4th animation kills my pc, the browser hangs and in the task manager I can see that it consumes up to 70% of CPU. How can I avoid this and free the resources so all the animations run smoothly.

*I have to execute 10 simple y-axis transformation animations on that character.

JS Fiddle

window.onload = function(){  
var paper = Raphael(0,0,400,400);

    var character = paper.set();
    paper.setStart();
    var attr = {fill:'red',stroke:'none'};  

    var shape = paper.rect(100,100,10,20).attr(attr);
    var shape = paper.rect(100,100,10,20).attr(attr);
    var shape = paper.rect(100,100,10,20).attr(attr);
    var shape = paper.rect(100,100,10,20).attr(attr);
    var shape = paper.rect(100,100,10,20).attr(attr);
    var shape = paper.rect(100,100,10,20).attr(attr);
    var shape = paper.rect(100,100,10,20).attr(attr);
    var shape = paper.rect(100,100,10,20).attr(attr);
    var shape = paper.rect(100,100,10,20).attr(attr);
    var shape = paper.rect(100,100,10,20).attr(attr);
    var shape = paper.rect(100,100,10,20).attr(attr);
    var shape = paper.rect(100,100,10,20).attr(attr);
    var shape = paper.rect(100,100,10,20).attr(attr);
    var shape = paper.rect(100,100,10,20).attr(attr);
    var shape = paper.rect(100,100,10,20).attr(attr);
    var shape = paper.rect(100,100,10,20).attr(attr);
    var shape = paper.rect(100,100,10,20).attr(attr);
    var shape = paper.rect(100,100,10,20).attr(attr);
    var shape = paper.rect(100,100,10,20).attr(attr);
    var shape = paper.rect(100,100,10,20).attr(attr);

    var character = paper.setFinish();
    character.transform("t0,200")



    //1st animation..
    var chartrnsfrm = Raphael.animation({
        transform:'...t0,-48'        
    },1000,"easeout",function(){
        character.animate(chartrnsfrm1.delay(2000))
    });
    character.animate(chartrnsfrm.delay(2000));


    //2nd animation..
    var chartrnsfrm1 = Raphael.animation({
        transform:'...t0,-48'        
    },1000,"easeout",function(){
        character.animate(chartrnsfrm2.delay(2000))
    });


    //3rd animation..
    var chartrnsfrm2 = Raphael.animation({
        transform:'...t0,-48'        
    },1000,"easeout",function(){
        character.animate(chartrnsfrm3.delay(2000))
    });


    //4th animation..
    var chartrnsfrm3 = Raphael.animation({
        transform:'...t0,-48'        
    },1000,"easeout");
}
  • 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-13T19:36:52+00:00Added an answer on June 13, 2026 at 7:36 pm

    You are expecting the callbacks from animation to work differently than they actually do.

    The variable character holds a set of paths. Raphaël does not currently map those to groups that would animate all children at once. What is going on here is that each path is animated seperately. In effect, each such animation is triggering a callback when it is done. That way, for the first animation, chartrnsfrm1, the callback is triggered 20 times. You therefore schedule the second animation, chartrnsfrm2, for the whole character 20 times. By the time you reach chartrnsfrm3, your callback is being triggered 20^3 = 8000 times. Scheduling those animations is what kills your browser.

    What I have done is remember the last shape, and only schedule the animation of the whole character if the element that the current callback is being called for (this) is equal to the lastShape.

    var lastShape = shape;
    
    //1st animation.. 
    var chartrnsfrm = Raphael.animation({
        transform:'...t0,-48'        
    },1000,"easeout",function(){
        if (lastShape == this)
            character.animate(chartrnsfrm1.delay(2000))
    });
    character.animate(chartrnsfrm.delay(2000));
    

    You can see the whole updated fiddle here, it has the fourth animation enabled and all of them run smoothly.

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

Sidebar

Related Questions

I have a line, which is a sprite made by using this code CGPoint
I have made this code: var foo=document.createElement(div); var childs=foo.getElementsByTagName(*); console.log(childs.length);//0 OK var a=document.createElement(a); foo.appendChild(a);
I have made this code to open a database(created in SQLite browser) stored in
I have a problem, and I made this test code to show you my
Using the following code, and inspired by this question, I managed to have vertical
I have this code <div id=main style=background:#aaaaaa;float:left;height:160px;margin:5px;position:relative;display:block;width:630px;> <div id=1 class=item style=background:#ffaacc;float:left;width:200px;height:150px;margin:5px;position:absolute;left:0px;top:0px;> </div> <div id=2
I have this code : void Main() { System.Timers.Timer t = new System.Timers.Timer (1000);
I have this code for changing the image of a button: - (void)mouseEntered:(NSEvent *)event
I have this code in XAML <Grid x:Name=LayoutRoot Background=Transparent> <Grid.RowDefinitions> <RowDefinition Height=Auto/> <RowDefinition Height=*/>
I have this code: EditText value = ( EditText )findViewById( R.id.editbox ); Integer int_value

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.