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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:41:30+00:00 2026-06-18T12:41:30+00:00

Is there any way to toggle the transformations you do in RaphaelJS? As of

  • 0

Is there any way to toggle the transformations you do in RaphaelJS? As of right now the below code works to make the circle bigger when clicked. What I need is to toggle the transformation so I can click again, and then the circle shrnks and moves back into place.

window.onload = function() {
    centerX = 300;
    centerY = 300;
    var paper = new Raphael(document.getElementById('canvas_container'), 900, 900);

    //setup main circle
    var mainCircle = paper.circle(centerX,centerY,90);
    mainCircle.attr(
        {
            gradient: '90-#526c7a-#64a0c1',
            stroke: '#3b4449',
            'stroke-width': 10,
            'stroke-linejoin': 'round',
            rotation: -90  
        }  
    );


    //when clicking main circle
    mainCircle.click( function(e) {

        //move and grow the main circle
        mainCircle.animate({cx:00, cy:00, r:100}, 1000, "easeout");
        mainCircle.animate({
                "transform": "s " + (s = 3)}, 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-18T12:41:31+00:00Added an answer on June 18, 2026 at 12:41 pm

    There’s a simple trick you can apply to toggle animation attributes (or any object for that matter); put them in an array and call them alternately by referring to a numeric switch as the index:

    var animAttrArr = [{
        "transform": "s 3"
    }, {
        "transform": "s 1"
    }],
        now = 1;
    
    mainCircle.click(function (e) {
        this.animate(animAttrArr[+(now = !now)], 1000, "easeout");
    });
    

    We’re simply using the soft types in JavaScript to our benefit — numbers can be evaluated to boolean values and act as flags.

    See a live demo on jsFiddle.


    • As a side note, I’d suggest adding a call to stop() before triggering any animation, as to prevent overlapping animations, e.g.:

      this.stop().animate(animAttrArr[+(now = !now)], 1000, "easeout");
      
    • As another side note, the code can be updated to support toggling of n > 2 transformations by extracting the modulo of the counter and the array length, and then increment it (thanks, @gion_13):

      this.stop().animate(animAttrArr[now++ % animAttrArr.length], 1000, "easeout");
      

      The modulo operation will take precedence over the increment, so don’t worry about hitting +Infinity (in case you got really concerned 🙂 ).

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

Sidebar

Related Questions

Is there any way i can change the toggle function or any of it's
Is there any way to achieve compiling Node.js scripts as native code, like Hip-Hop
Is there any easy way to toggle do/end and {} in ruby in Vim?
It looks like jQM uses CSS checkboxes. Is there any simple way to toggle
Is there any way in Notepad++ (or even with another tool) to change the
Is there any way I can set a formatter on models that will convert
Is there any way to use Google's API to retrieve a user's current zipcode
Is there any way to overload the > (greater than) operator, to be able
Is there any way we can fetch X509 Public Cetrificates using c# from AD
Is there any way to stop animation in iOS 3 ? I know about:

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.