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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:53:54+00:00 2026-05-30T01:53:54+00:00

All, I am trying create a ‘to & fro’ animation using jquery animate &

  • 0

All,

I am trying create a ‘to & fro’ animation using jquery animate & css transform property.

I referred to this SO post on using step function in animate, however, Im not having much success. Please review & advice.

Jsfiddle.net demo

HTML:

<ul id="a">
<li class="cAccessories" id="AccButtons"><span>blah blah..</span></li>
<li class="cAccessories" id="AccRibbons"><span>blah blah..</span></li>
<li class="cAccessories" id="AccLaces"><span>blah blah..</span></li>
<li class="cAccessories" id="AccEmbroider"><span>blah blah..</span></li>
</ul>   

CSS:

#a {
    position: absolute;
    top: 25px;
    left: 25px;
    width: 150px;
    height: 150px;
    padding: 0;
    margin: 0;
    list-style: none;
    background-color: blue;
}

JAVASCRIPT:

$("#a").animate ({"margin-left": "+=10px"}, {step: function (now, fx) {
$("#a").css ("-moz-transform", "rotate('5deg')");
$("#a").css ("-webkit-transform", "rotate ('5deg')");
$("#a").css ("-ms-transform", "rotate ('5deg')");
$("#a").css ("-o-transform", "rotate ('5deg')");
}, duration: "slow"}, "linear", function ()
{
$("#a").animate ({left: "+=0px"}, {step: function (now, fx) {
$("#a").css ("-webkit-transform", "rotate ('-5deg')");
$("#a").css ("-moz-transform", "rotate ('-5deg')");
 $("#a").css ("-ms-transform", "rotate ('-5deg')");
$("#a").css ("-o-transform", "rotate ('-5deg')");
}, duration: "slow"}, "linear" ); });

Following is the original code, which I doesn’t like the transform animation (even though it animates the ‘top’ value perfectly).

iTemplateNo = $(this).attr("id").substr (-1, 1);
eCurHanger = document.getElementById("hanger0" + iTemplateNo);
$(eCurHanger).attr("src", "Img/V2/Hanger.png");
$(eCurHanger).css ({"width": "45px", "height": "35px"});
$(eCurHanger).animate ({top: "+=10px"}, {step: function (angle, fx) {
$(eCurHanger).css ({"-webkit-transform": "rotate ("+angle+"deg)",
      "-moz-transform": "rotate ("+angle+"deg)",
      "-ms-transform": "rotate ("+angle+"deg)",
      "-o-transform": "rotate ("+angle+"deg)"});
   }, duration: 1000}, "linear", function ()
   {
    $(eCurHanger).animate ({left: "+=10px"}, {step: function (angle, fx) {
    $(this).css ({"-webkit-transform": "rotate("+angle+"deg)",
    "-moz-transform": "rotate("+angle+"deg)",
    "-ms-transform": "rotate("+angle+"deg)",
    "-o-transform": "rotate("+angle+"deg)"})
   }, duration: 1000}, "linear" ) });

  • 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-30T01:53:55+00:00Added an answer on May 30, 2026 at 1:53 am

    I do not know what eCurHanger is, but look here http://jsfiddle.net/8tP9D/

    var angle = 0;
    $("#a").animate ({"margin-left": "+=200px"}, {step: function (now, fx) {
        angle += 1;
        $(this).css ({"-moz-transform":"rotate("+angle+"deg)",
                      "-webkit-transform":"rotate("+angle+"deg)",
                      "-ms-transform":"rotate("+angle+"deg)",
                      "-o-transform":"rotate("+angle+"deg)"});
    }, duration: 5000}, "linear");
    

    instead of global angle you could use now variable. http://jsfiddle.net/39pe6/

    $("#a").animate ({"margin-left": "+=200px"}, {step: function (angle, fx) {
        $(this).css ({"-moz-transform":"rotate("+angle+"deg)",
                      "-webkit-transform":"rotate("+angle+"deg)",
                      "-ms-transform":"rotate("+angle+"deg)",
                      "-o-transform":"rotate("+angle+"deg)"});
    }, duration: 5000}, "linear");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi all im trying to create a loading animation with html and JQuery that
I'm trying to create a css menu bar that has all grey text with
I'm trying to create a page by using view 2. This page list all
I am trying to create a menu panel in jQuery, all is complete except
I'm trying to create a check/uncheck all CheckBox for a number of CheckBoxes that
I'm trying to create a splash screen that shows assemblies (all referenced library) loading
I'm trying to create a Regex to block all < and > in a
I'm trying to create a utility class for traversing all the files in a
I'm trying to create a good way to handle all possible collisions between two
I'm trying to create a SharePoint web part that will display all the users

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.