Reply To: Track Mouse Position

PennController for IBEX Forums Requests Track Mouse Position Reply To: Track Mouse Position



You can’t control the cursor’s position, as that would pose serious security issues. You could, in theory, center the image at the cursor’s coordinates, but that’s not how I wrote the DragDrop element. What you could do to modify the behavior of the DragDrop element is upload PennElement_dragdrop.js to your project’s Modules folder, and look for these lines in the file:

start = {x: ev.clientX, y: ev.clientY, top:, left: rect.left, 
        old_top:, old_left:, old_position:};
$({position: 'fixed', top:, left: rect.left});

and replace them with:

const newtop = ev.clientY - rect.height/2, newleft = ev.clientX - rect.width/2;
start = {x: ev.clientX, y: ev.clientY, top: newtop, left: newleft, 
        old_top:, old_left:, old_position:};
$({position: 'fixed', top: newtop, left: newleft});

You’ll get a warning that the element type DragDrop is defined more than once when test-running the experiment, but other than that it should work as expected