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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:52:32+00:00 2026-06-14T01:52:32+00:00

I guess this would apply to swinging, or bouncing. An example on how to

  • 0

I guess this would apply to swinging, or bouncing. An example on how to make an object swing here in another post, where this code was posted: http://jsfiddle.net/gVCWE/149/

How would you make the swinging slow down to a stop?

.box{
    width:50px; height:50px;
    background: yellow;
    border: 1px solid black;
    margin:100px;
    position: relative;
    float: left;
    -moz-animation: 3s ease 0s normal none infinite swing;
    -moz-transform-origin: center top;
    -webkit-animation:swing 3s infinite ease-in-out;
    -webkit-transform-origin:top;
}

@-moz-keyframes swing{
    0%{-moz-transform:rotate(-3deg)}
    50%{-moz-transform:rotate(3deg)}
    100%{-moz-transform:rotate(-3deg)}
}
@-webkit-keyframes swing{
    0%{-webkit-transform:rotate(-3deg)}
    50%{-webkit-transform:rotate(3deg)}
    100%{-webkit-transform:rotate(-3deg)}
}

I would like to do other ‘inertia effects’ as well. I do not mind using JavaScript or JQuery if that’s necessary. I feel like CSS alone or keyframes is not enough for what I want to do.

I’m fine using setInterval and doing something like this:

function prepareAnimation()
{
    setInterval(slowAnimation, 200)
}

function slowAnimation()
{
    speed=$(".box").getSpeed(); // how would I write getSpeed?
    if(speed<=0) return;
    speed = speed - .1;
    $(".box").setSpeed(speed); // how would I write setSpeed (degree would be set in here too)?
}

I do not know the best way to changing animation properties through script. Especially when it comes to changing the duration in the middle of an animation, which I’m not sure is possible at all. Thanks.

  • 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-14T01:52:33+00:00Added an answer on June 14, 2026 at 1:52 am

    http://jsfiddle.net/gVCWE/150/

    (function swing() {
        var ang  = 20,
            dAng = 1,
            dir  = 1,
            box = document.getElementById("box");
    
        (function setAng(ang){
            box.style.WebkitTransform =  'rotate('+ang+'deg)';
            box.style.MozTransform =  'rotate('+ang+'deg)';
            dir = -dir;
            if (Math.abs(ang) > 0)
                setTimeout(setAng, 1000, dir * (Math.abs(ang)-dAng));
        })(ang);
    })();​
    

    CSS

    .box{
        width:50px; height:150px;
        background: yellow;
        border: 1px solid black;
        margin:100px;
        position: relative;
        float: left;
        -moz-transition:-moz-transform 1s ease-in-out;
        -moz-transform-origin: center top;
        -webkit-transition:-webkit-transform 1s ease-in-out;
        -webkit-transform-origin:top;
    }
    

    You can switch the initial direction by making the initial values of ang and dir negative. You can make the “swinging” slow more quickly by increasing the value of dAng, but it should be a factor of ang.

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

Sidebar

Related Questions

I guess another way to phrase this would be Is there a class like
I knew this day would come, so I guess it is here. (P.S. I
I guess this question will sound familiar, but I am yet another programmer baffled
This particular example relates to Django in Python, but should apply to any language
I guess this is a simple question. I need to do something like this:
I guess this is similar to what Facebook does, but...I haven't worked out how
I guess this is kind of an odd question but I have tried setting
Okay guess this question looks a lot like: What is the best way to
I guess this is a continuation of the last question I asked: bulk insert
I guess this is fairly simple for you but i cant wrap my head

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.