title: Javascript / CSS - Rotation after CSS animation
body: <p>I'm messing around with CSS animations at the moment and there is this behaviour I came across that I don't understand.</p>
  <p>I have a div container to which I set an infinite CSS animation. The animation will just rotate the div back and forth. At any given point I want to manually adjust the rotation of the div to a specific and absolute angle (-90 degress in my case).</p>
  <p>The problem I'm experiencing is, that whenever I (or animejs) is trying to set the rotation to the fixed -90 degrees after the CSS animation has started, the following rotation somehow depends on the CSS animation changes. I also tried to pause the CSS animation before without success.</p>
  <p>I just want to trigger an animejs animation that always goes smoothly to -90 degrees from its current state (given by the CSS animation).</p>
  <p>Here is an example of what I'm talking about:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var div = document.getElementById('testdiv');
  
  document.addEventListener('keypress', function onPress(event) {
      div.style.animationPlayState = 'paused';
  
      if (event.key == 'q') {
        div.style.transform = 'rotate(-90deg)'; 
      }
  
      if(event.key == 'e') {
        div.style.transform = 'rotate(180deg)'; 
      }
  
      if(event.key == 's') {
        div.style.animationPlayState = 'running';
      }
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>@keyframes animation {
      to {
          transform: rotate(15deg); 
      }
  }
  
  #testdiv {
      position: absolute;
      background-color: black;   
      margin: auto;
      margin-top: 50px;
      width: 200px;
      height: 150px;
  
      animation-name: animation;
      animation-duration: 1s;  
      animation-direction: alternate;
      animation-iteration-count: infinite;
      animation-fill-mode: forwards;
      animation-play-state: paused;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="testdiv"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  <p><a href="https://jsfiddle.net/Ls1ytf4h/" rel="nofollow noreferrer">https://jsfiddle.net/Ls1ytf4h/</a></p>
  <p><code>&lt;div id=&quot;testdiv&quot;&gt;&lt;/div&gt;</code></p>
  <p>If you run this and press Q or E in its inital state, it will change its rotation to either -90 or 180 degrees. If you press S, it will start the inifite CSS animation. After the animation started, press Q or E again (switch multiple times from Q to E to see the difference).
  As you can see it doesn't go back to the absolute -90 degrees. It seem to work relative to something, but I cannot figure out to what. animejs is working in the same weird way, when I try to smoothly go to the -90 degrees from its current state.</p>
  <p>Is there some way to avoid this behaviour?</p>
  <p>Btw. was my first question here, so I hope I didn't do something wrong ;)</p>
  <p>Kind regards!</p>