Changing scrollTop does not continue inertia scrolling
<p>I have a div with scrollable content that at a certain scrollTop value goes back to top.</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 container = document.getElementById('container');

function scroll_function() {

  var new_position_top = container.scrollTop;

  if (new_position_top &gt; 600) {

    container.scrollTop = 0;

  }

}

container.addEventListener('scroll', scroll_function);</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>#container {
  width: 300px;
  height: 300px;
  overflow: auto;
  border: 1px solid black;
  -webkit-overflow-scrolling: touch;
}
span {
  width: 100%;
  height: 1200px;
  float: left;
  background: red;
  background: -webkit-linear-gradient(red, yellow);
  background: -o-linear-gradient(red, yellow);
  background: -moz-linear-gradient(red, yellow);
  background: linear-gradient(red, yellow);
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="container"&gt;
  &lt;span&gt;&lt;/span&gt;
&lt;/div&gt;</code></pre>
</div>
</div>
</p>

<p><a href="https://jsfiddle.net/5gtvezth/1/" rel="nofollow noreferrer">JSFiddle</a>.</p>

<p>Using a MacBook trackpad I am getting different behaviours:
Chrome and Safari work as I would expect, continuing the inertia after going back to the top.
<strong>Firefox</strong>, however, goes back to the top and stops the inertia.</p>

<p>Using <strong>iOS Safari</strong> a similar issue appears too, as the scrollTop position is not updated until the inertia finishes.</p>

<p><strong>Is there a better way of approaching it or a way to fix desktop Firefox and iOS Safari behaviour?</strong></p>