Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Spinning with JavaScript problem

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #37605
    cpyle0819
    Participant

    Hey all, working on a site and everything is going ok so far. When I click a button (the black one on the left of the screen for now) my gear spins…when I click it again, it resets its angle and starts the animation over. I want it to continue from it’s new angle so it’s a smooth animation on every click. I’m sure it’s some simple JS that just needs to be plopped in but I can’t figure it out. Thanks in advance!

    #101104
    TheDoc
    Member

    Every time you start the animation, it starts at 0 because that’s what you have your variable ‘ang’ set to. You need to find a way to check the current value of the rotation on each click and only add 45 to that number.

    #101145
    cpyle0819
    Participant

    So should I write another function that gets the current angle and sets the variable to that angle or is it possible to include it in my current one?

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.