title: Jumpy behavior while creating sticky header using css transform
body: <p>I am trying to implement a sticky header row for table, but need to do it without position: sticky property.</p>
  <p>The approach I am going for is translating Y coordinate of header row along with document vertical scroll by same amount of pixels.</p>
  <p>As the document is scrolled down, we translate the header row downwards by same number of pixels giving the effect that header row is stuck at the top of table.</p>
  <p>I have a working implementation at <a href="https://codepen.io/shubham_687/pen/porPwbP" rel="nofollow noreferrer">https://codepen.io/shubham_687/pen/porPwbP</a></p>
  <p>PFA the gist of implementation below</p>
  <pre><code>  canvas.onscroll = function (e) {
     if (canvas.scrollTop &gt;= rect.top) {
       const numOfPixels = canvas.scrollTop - rect.top;
        element.setAttribute(
         &quot;style&quot;,
         &quot;transition:0s;transform: translate3d(0px,&quot; + numOfPixels + &quot;px, 0px);&quot;
        );
     } else {
        element.setAttribute(
         &quot;style&quot;,
         &quot;transition:0s;transform: translate3d(0px, 0px, 0px);&quot;
        );
      }
   };
  </code></pre>
  <p>The issue I am facing is that the implementation is jerky/sluggish/jumpy in some browsers and mobile devices while working perfectly fine in some (Google chrome).</p>
  <p>As per my understanding, this behavior might be because of the following reason(s)</p>
  <ol>
  <li><p>Large number of scroll events per second causing perf impact, might be possible to solve using debouncing, any suggestions?</p>
  </li>
  <li><p>Updating css dynamically leads to update layer tree which takes some time as well and the number of times this gets called is directly proportional to the times scroll event is registered.</p>
  </li>
  </ol>
  <p>Please share possible suggestions for perf improvement.</p>