Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<div id="dialog"></div>
 
var top1=0,left1=0; 
var moveFunction = function(event){
    console.log('x=',event.clientX);
    console.log('y=',event.clientY);
    console.log('ox=',event.offsetX);
    console.log('oy=',event.offsetY);
    document.getElementById('dialog').style.top =  event.clientY - top1+ "px";
     document.getElementById('dialog').style.left = event.clientX - left1 + "px";
 };
var mousedownFunction = function(event){
  var obj = document.getElementById('dialog');
  top1 = event.offsetY; //event.clientY - obj.offsetTop;
  left1 = event.offsetX;//event.clientX - obj.offsetLeft;
  document.getElementById('dialog').addEventListener('mousemove',moveFunction);
}
document.getElementById('dialog').addEventListener('mousedown',mousedownFunction);
document.getElementById('dialog').addEventListener('mouseup',function(){
  document.getElementById('dialog').removeEventListener('mousemove',moveFunction);
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers