title: CSS Transition Animation Jank w/zindex on Mac (Retina)
body: <p>We have an Angular 4 web app with a sidenav. When clicking on the hamburger icon, the sidenav animates open from right to left by giving it a width via JS and a transition via CSS, and the main content div in the background is faded to a black with opacity.</p>
  
  <p>The issue is the clunky opening animation, jank, on the opening and closing of the sidenav.</p>
  
  <p>Please bare in mind I'm still a fairly new to Angular. The code is:</p>
  
  <pre><code>public openNav() {
      let offCanvas = document.getElementById('off-canvas-menu');
      let container = document.getElementById('main-wrapper-container');
      let openIndex = document.getElementById('main-view-container');
  
      offCanvas.style.width = "250px";
      openIndex.style.zIndex = '-1';
  
      setTimeout(function() {container.style.background = "rgba(0,0,0,0.4)"}, 200);
  
  }
  
  public closeNav() {
      document.getElementById('off-canvas-menu').style.width = "0";
      document.getElementById('main-wrapper-container').style.background = "inherit";
      let closeIndex = document.getElementById('main-view-container');
      setTimeout(function() { closeIndex.style.zIndex = 'auto'}, 300);
  }
  </code></pre>
  
  <p>The reason I have it set up with zindex is because there seems to be an issue with the views from the other components. If I remove the zindex, then the transparent to black with opacity doesn't show up on top, it stacks below the main content. I've tried everything to get to stack right (playing with zindex in differnet divs, adding positioning in CSS) but not sure if this is an issue with Angular or if I missed something, or if the code above is just bad. If I remove the zindex the animation is smoother.</p>
  
  <p>Also, this is more noticeable on Macs with Google Chrome and Safari (even more prevalent on a retina screen), on Firefox works ok, on Windows works ok.</p>
  
  <p>Looking forward to any feedback!</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;span (click)="openNav()" id="open-off-canvas-menu-button" *ngIf="is_there_session()"&gt;
      &lt;i class="fa fa-bars" aria-hidden="true"&gt;&lt;/i&gt;
  &lt;/span&gt;
  
  &lt;div id="main-wrapper-container" (click)="closeNav()"&gt;
    &lt;div id="main-view-container"&gt;
      &lt;router-outlet&gt;&lt;/router-outlet&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>SASS:</p>
  
  <pre><code>#open-off-canvas-menu-button{
      position: fixed;
      top: 0;
      right:0;
      padding: 25px 18px 0 0;
      z-index: 500;
      i{
          display: inline-block;
          color: $gray-forty;
          transition: color 500ms ease-in-out;
          font-size: 18px;
      }
  
      &amp;:hover {
          cursor: pointer;
      }
  }
  
  
  .off-canvas-menu {
      height: 100%;
      width: 0;
      position: fixed;
      top: 0;
      right: 0;
      background-color: $black;
      overflow-x: hidden;
      padding-top: 60px;
      @include transition(all .5s ease);
      z-index: 1000;
  }
  
  .off-canvas-menu a {
      padding: 8px 8px 8px 32px;
      text-decoration: none;
      font-size: 1.5rem;
      color: $gray-forty;
      display: block;
      width: 300px;
      @include transition(all .5s ease);
      &amp;:hover {
          cursor: pointer;
      }
  }
  
  .off-canvas-menu a:hover, .offcanvas a:focus{
      color: #f1f1f1;
  }
  
  .off-canvas-menu .closebtn {
      position: absolute;
      top: 5px;
      transform: translateX(60%);
      font-size: 36px;
  }
  
  #main-wrapper-container {
      position: relative;
      height: 100%;
      min-height: 100vh;
      width: 100%;
      @include transition(all .4s ease);
  }
  
  #main-view-container {
      position: relative;
  }
  </code></pre>