title: How can I escape object while mouse is approaching to it
body: <p>I have an issue about <strong>escaping object to left side every time while the mouse is approaching to it</strong>.
  I wrote a code snippet but it doesn't work very well.
  How can I fix it?</p>
  
  <p>Here is my code snippet shown below.</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>$(document).mousemove(function(event){
    CurrentMouseXPostion = event.pageX;
    CurrentMouseYPostion = event.pageY;
   
    var x = $("div").position();
    
    if(CurrentMouseXPostion - x.top == 1 &amp;&amp; CurrentMouseYPostion - y.top == 1) {
      $("div").animate({left: '250px'});
    }        
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>div {
    background:#98bf21;
    height:100px;
    width:100px;
    position:absolute;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Thank you.</p>