How can I rotate an image -360 degrees and +360 degrees using -webkit and jQuery?


username

I found an example of infinitely rotating a div - how to trigger a css3 rotation effect on click? Here is http://jsfiddle.net/yNT3L/ on jsFiddle, here is the code used on jsFiddle -

// css

    width: 100px;
    height: 100px;
    background-color: red;
    margin: 50px 50px 50px 50px;
}

#d2{
    background-color: green;
    -webkit-animation: spin 10s infinite linear;
}

.spinEffect{
    -webkit-animation: spin 0.5s 1 linear;
}

@-webkit-keyframes spin {
0%  {-webkit-transform: rotate(0deg);}
100% {-webkit-transform: rotate(360deg);}   
}

// jQuery

$(function(){
    $("a").click(function(){
        $("#d1").addClass(".spinEffect");
    });
});

It seems to target -webkit's spin element, and I'm just wondering how to set the value of the spin element to 360 degrees and the other div to be -360 degrees?

Andrew Wilkinson

spinis the custom name for the keyframe specification, it's not built into webkit. All you need to do is create a new keyframe project with a different name and reference it.

#d3{
    background-color: blue;
    -webkit-animation: spinreverse 10s infinite linear;
}

@-webkit-keyframes spinreverse {
    0%  {-webkit-transform: rotate(0deg);}
    100% {-webkit-transform: rotate(-360deg);}   
}

I updated your jsfiddle to http://jsfiddle.net/yNT3L/157/

Related


Rotate UIButton 360 degrees

Nadal Arriafa I've been trying to run an animation that rotates 360 degrees UIButtonusing the following code : UIView.animateWithDuration(3.0, animations: { self.vineTimeCapButton.transform = CGAffineTransformMakeRotation(CGFloat(M_PI*2)) self.instagramTim

Rotate a view 360 degrees indefinitely in Swift?

Cesare I want to rotate the image view 360 degrees indefinitely. UIView.animate(withDuration: 2, delay: 0, options: [.repeat], animations: { self.view.transform = CGAffineTransform(rotationAngle: 6.28318530717959) }, completion: nil) what should I do? Cra

How to make OpenGL camera rotate 360 degrees

kilobit I'm currently working on entity motion, but I've noticed that the camera only has a "180 degree" "view" and doesn't go beyond this position. Trying to turn after the threshold, or whatever, will make the camera really slow and take a long time to come

Rotate a view 360 degrees indefinitely in Swift?

Cesare I want to rotate the image view 360 degrees indefinitely. UIView.animate(withDuration: 2, delay: 0, options: [.repeat], animations: { self.view.transform = CGAffineTransform(rotationAngle: 6.28318530717959) }, completion: nil) what should I do? Cra

Rotate NSView 360 degrees

Tom Cuomo I have this code below to rotate a UIView 360 degrees. It is an extension file of UIView. extension NSView { func rotate360Degrees(duration: CFTimeInterval = 0.5, completionDelegate: AnyObject? = nil) { let rotateAnimation = CABasicAnimation(keyP

Rotate UIButton 360 degrees

Nadal Arriafa I've been trying to run an animation to rotate 360 degrees UIButtonusing the following code : UIView.animateWithDuration(3.0, animations: { self.vineTimeCapButton.transform = CGAffineTransformMakeRotation(CGFloat(M_PI*2)) self.instagramTimeCa

Rotate a view 360 degrees indefinitely in Swift?

Cesare I want to rotate the image view 360 degrees indefinitely. UIView.animate(withDuration: 2, delay: 0, options: [.repeat], animations: { self.view.transform = CGAffineTransform(rotationAngle: 6.28318530717959) }, completion: nil) what should I do? Cra

Rotate a graphic object 360 degrees

jumper I have two points (x1, x2, y1, y2) which form a vertical line. When the user rotates the object, I know these two points, the question is: how to find the coordinates of the other two points that form the horizontal line. How to implement it easily? I w

Rotate UIButton 360 degrees

Nadal Arriafa I've been trying to run an animation that rotates 360 degrees UIButtonusing the following code : UIView.animateWithDuration(3.0, animations: { self.vineTimeCapButton.transform = CGAffineTransformMakeRotation(CGFloat(M_PI*2)) self.instagramTim

Rotate from quaternion to degrees (0-360°)

Danny I've installed a Google Project Tango device sideways on a bot and want to get the title from onPoseAvailable()an event listener . I know the framework returns quaternions as described in the API. I have tried a lot to convert the quaternion to a measure

Rotate a graphic object 360 degrees

jumper I have two points (x1, x2, y1, y2) which form a vertical line. When the user rotates the object, I know these two points, the question is: how to find the coordinates of the other two points that form the horizontal line. Is it easier to implement? I wi

Attempt to rotate the object 360 degrees

User 13245026 My swift code is trying to do a 360 rotation on an image view called box. But the code does rotate because I am using the code self.box.transform = self.box.transform.rotated(by: CGFloat.pi * 2) to do a 360 degree rotation. Pi *2 is a 360 degree

Rotate the picture 360 degrees

Rohit Need developer help, I am using image for menu. I just want to rotate the image 360 degrees when clicked and open another page. I try this. <style> .image { overflow: hidden; transition-duration: 0.8s; transition-property: tra

ios how to rotate control 360 degrees

AYMADA I want to rotate the control 360 degrees. I'll do that now #define degreesToRadians(x) (M_PI * x / 180.0) [UIView animateWithDuration:0.25 delay:0.0 options:UIViewAnimationOptionCurveEaseOut animations:^{ [self.crossButton setTransform:CGAffineTran

How to make OpenGL camera rotate 360 degrees

kilobit I'm currently working on entity motion, but I've noticed that the camera only has a "180 degree" "view" and doesn't go past this position. Trying to turn after the threshold, or whatever, will make the camera really slow and take a long time to come ba

Animate Rotate from 360 degrees to 0 degrees - iOS sensor

Malakos When I try to animate the rotation mapped to the iOS compass, the animation does a full turn in the opposite direction. For CSS3 transitions, there is a related question about this, suggesting that I should keep adding degrees beyond 360 and it wraps a

Rotate NSView 360 degrees

Tom Cuomo I have this code below to rotate a UIView 360 degrees. It is an extension file of UIView. extension NSView { func rotate360Degrees(duration: CFTimeInterval = 0.5, completionDelegate: AnyObject? = nil) { let rotateAnimation = CABasicAnimation(keyP

Rotate NSView 360 degrees

Tom Cuomo I have rotated the UIView 360 degrees in the code below. It is an extension file of UIView. extension NSView { func rotate360Degrees(duration: CFTimeInterval = 0.5, completionDelegate: AnyObject? = nil) { let rotateAnimation = CABasicAnimation(ke

Rotate a view 360 degrees indefinitely in Swift?

Cesare I want to rotate the image view 360 degrees indefinitely. UIView.animate(withDuration: 2, delay: 0, options: [.repeat], animations: { self.view.transform = CGAffineTransform(rotationAngle: 6.28318530717959) }, completion: nil) what should I do? Cra

Rotate UIButton 360 degrees

Nadal Arriafa I've been trying to run an animation that rotates 360 degrees UIButtonusing the following code : UIView.animateWithDuration(3.0, animations: { self.vineTimeCapButton.transform = CGAffineTransformMakeRotation(CGFloat(M_PI*2)) self.instagramTim

Rotate a graphic object 360 degrees

jumper I have two points (x1, x2, y1, y2) which form a vertical line. When the user rotates the object, I know these two points, the question is: how to find the coordinates of the other two points that form the horizontal line. Is it easier to implement? I wi

ios how to rotate control 360 degrees

AYMADA I want to rotate the control 360 degrees. I'll do that now #define degreesToRadians(x) (M_PI * x / 180.0) [UIView animateWithDuration:0.25 delay:0.0 options:UIViewAnimationOptionCurveEaseOut animations:^{ [self.crossButton setTransform:CGAffineTran

Rotate NSView 360 degrees

Tom Cuomo I have rotated the UIView 360 degrees in the code below. It is an extension file of UIView. extension NSView { func rotate360Degrees(duration: CFTimeInterval = 0.5, completionDelegate: AnyObject? = nil) { let rotateAnimation = CABasicAnimation(ke

CSS rotate 360 degrees

High 83 I want to rotate a rectangle 360 degrees (even > 360 degrees) using CSS. The center of rotation is the "right center". If I use the following CSS code to rotate 180 degrees (and use JavaScript to trigger the rotation) it works fine: .animated.rotation