-1

I am trying to create a code if mouse goes outside for example I move my mouse outside right and my mouse comes back on the left side like in Blender.

var x, y;

function handleMouse(e) {
   if (x && y) {
      window.scrollBy(e.clientX - x, e.clientY - y);
   }
   x = e.clientX;
   y = e.clientY;
   /* That code I need goes here... */
}
document.onmousemove = handleMouse;

I am a bit desperately.

Liwu
  • 14
  • 1
  • 6
  • Use `document.body.onmousemove` instead – igasparetto Aug 27 '15 at 21:38
  • That code works but I can't create a code for that what I need. – Liwu Aug 27 '15 at 21:40
  • I don't get what you need. Can you rephrase it please? – igasparetto Aug 27 '15 at 21:41
  • I want to add a script that's allow when the mouses moves outside of the scrren that the mouse is coming back from that another side. – Liwu Aug 27 '15 at 22:20
  • Please describe your idea of what you're trying to accomplish so others may help you better... are you trying to do something like click and drag a box and you want to move the box to a new location when the mouse re-enters from another area?? – Tcll Aug 30 '15 at 16:49
  • Your screen is 640x480 and your mouse moves to the corrdinates: 641x110. So your mouse is outside? No I want that the mouse come bacl at: 0x110. – Liwu Sep 02 '15 at 16:10
  • might want to fix up your question then to state you want to wrap the mouse. ;) – Tcll Sep 03 '15 at 18:20

1 Answers1

0

wrapping the mouse pointer is not possible as you would need to grab the pointer to move it to the other side of the DIV, or whatever you're using for your display area.

it's a security issue if your pointer cannot leave the webpage.

read more here: Move the mouse pointer to a specific position?

Community
  • 1
  • 1
Tcll
  • 7,140
  • 1
  • 20
  • 23
  • just thought I'd comment on the fact that SDL does this security issue... Nexuiz in particular is a game you have to close to get your pointer back... heh – Tcll Sep 18 '15 at 17:11
  • Thank you, this was that what I am looking for. – Liwu Apr 17 '17 at 22:25