Eyad Syria-lover Posted September 14, 2016 Share Posted September 14, 2016 Hello. I've Tried To Create An Animation (A Shape Which Rotate),But I'am Unable To Make It Stop. Here's The Code: http://jsbin.com/zevotu/edit How Can I Make This Animation Stop Rotating After It Rotate 270 Degree? Link to comment Share on other sites More sharing options...
justsomeguy Posted September 14, 2016 Share Posted September 14, 2016 You're keeping track of the degrees of rotation, so you can stop the interval whenever that hits the place you want to stop at. You should start the rotation at 0 instead of 360 though to make it more obvious. Link to comment Share on other sites More sharing options...
Eyad Syria-lover Posted September 14, 2016 Author Share Posted September 14, 2016 You're keeping track of the degrees of rotation, so you can stop the interval whenever that hits the place you want to stop at. You should start the rotation at 0 instead of 360 though to make it more obvious. Sir Can You Provide Me With A Code (If You Don't Mind)? Thanks In Advance... Link to comment Share on other sites More sharing options...
Ingolme Posted September 14, 2016 Share Posted September 14, 2016 You need to understand the theory, giving you code to copy and paste would hinder your ability to learn. Your code is starting degree at 360 and then adding 1 to it on every interval, so to count 270 degrees on top of that you would need to check for 360 + 270 degrees. When degree is equal to that amount, call clearInterval() to stop the animation Link to comment Share on other sites More sharing options...
dsonesuk Posted September 16, 2016 Share Posted September 16, 2016 Use if condition to reset to 0 if degree == 360, you can then use this in future for multiple rotations, then use if condition to apply clearInterval() if degree == 270. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now