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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:04:12+00:00 2026-05-18T09:04:12+00:00

i am working on a html5 interface wich uses drag and drop. While i

  • 0

i am working on a html5 interface wich uses drag and drop. While i am dragging an element, the target gets a css-class, which makes it bidirectionally rotate due to a -webkit-animation.

@-webkit-keyframes pulse {
   0%   { -webkit-transform: rotate(0deg);  }
   25%  { -webkit-transform:rotate(-10deg); }
   75%  { -webkit-transform: rotate(10deg); }
   100% { -webkit-transform: rotate(0deg);  }
  }

.drag
{
    -webkit-animation-name: pulse;
    -webkit-animation-duration: 1s;
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-timing-function: ease-in-out;
}

When I drop the target, I want it to adopt the current state of rotation.

My first thought was to check the css property with jquery and the .css(‘-webkit-transform’) method. But this method just returns ‘none’.

So my question: Is there a way to get the current degree value of an element which is rotated via animation?

Thanks so far
Hendrik

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

    I recently had to write a function that does exactly what you want! Feel free to use it:

    // Parameter element should be a DOM Element object.
    // Returns the rotation of the element in degrees.
    function getRotationDegrees(element) {
        // get the computed style object for the element
        var style = window.getComputedStyle(element);
        // this string will be in the form 'matrix(a, b, c, d, tx, ty)'
        var transformString = style['-webkit-transform']
                           || style['-moz-transform']
                           || style['transform'] ;
        if (!transformString || transformString == 'none')
            return 0;
        var splits = transformString.split(',');
        // parse the string to get a and b
        var parenLoc = splits[0].indexOf('(');
        var a = parseFloat(splits[0].substr(parenLoc+1));
        var b = parseFloat(splits[1]);
        // doing atan2 on b, a will give you the angle in radians
        var rad = Math.atan2(b, a);
        var deg = 180 * rad / Math.PI;
        // instead of having values from -180 to 180, get 0 to 360
        if (deg < 0) deg += 360;
        return deg;
    }
    

    Hope this helps!

    EDIT I updated the code to work with matrix3d strings, but it still only gives the 2d rotation degrees (ie. rotation around the Z axis).

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

Sidebar

Related Questions

I am working on a winforms html editor with multiple editor windows as each
I'm working with a bit of html and Javascript code that I've taken over
I'm working on a simple HTML scraper for Hulu in python 2.6 and am
The .NET web system I'm working on allows the end user to input HTML
I asked how to render a UserControl's HTML and got the code working for
I'm an email n00b but I am working on an application that sends HTML
My question is related to HTML, and PURE html. I am working on a
Working with dates in ruby and rails on windows, I'm having problems with pre-epoch
Working with a SqlCommand in C# I've created a query that contains a IN
Working on a project at the moment and we have to implement soft deletion

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.