title: Why is clientX reset to 0 on last drag-event and how to solve it?
body: <p>I'm trying to drag elements along a line. They should push each other, not cross over or under.</p>
  <p>To avoid having a shady element float around on drag, I drag a sub-div which then affects the position of the outer one. Works fine except when you release the mouse which triggers the last drag-event with <code>clientX</code> equal to <code>0</code> (see <a href="https://codepen.io/primavera133/pen/EKvbYV" rel="nofollow noreferrer">CodePen</a>)!</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 b = document.querySelector('.box');
  var bi = document.querySelector('.box-inner');
  var b2 = document.querySelector('.box2');
  
  bi.addEventListener('dragstart', function() {
    console.log("dragstart")
  }, false);
  
  bi.addEventListener('drag', function(event) {
    const bLeft = event.clientX;
    const b2Left = b2.offsetLeft;
    b.style.left = bLeft + "px";
    if (b2Left - 50 &lt;= bLeft) {
      b2.style.left = (bLeft + 50) + "px";
    }
  
    console.log("drag", event.clientX, event.target.offsetParent.offsetLeft, b2.offsetLeft);
  
  }, false);
  
  bi.addEventListener('dragend', function() {
    console.log("dragend")
  }, false);</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.box {
    width: 50px;
    height: 50px;
    background-color: hotpink;
    position: absolute;
    top: 0;
    left: 0;
  }
  
  .box-inner {
    width: 100%;
    height: 100%;
  }
  
  .box2 {
    width: 50px;
    height: 50px;
    background-color: rebeccapurple;
    position: absolute;
    left: 200px;
    top: 0;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="box"&gt;
    &lt;div class="box-inner" draggable="true"&gt;&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="box2"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>Why is this and what can I do to avoid resetting it?</p>