Caută ajutor

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Află mai multe

Acest fir de discuție a fost arhivat. Adresează o întrebare nouă dacă ai nevoie de ajutor.

SVG - dragging using 'onmousemove'

  • 2 răspunsuri
  • 1 are această problemă
  • 5 vizualizări
  • Ultimul răspuns de Charles Lindsey

more options

See http://home.clerew.man.ac.uk:7777/web/quickslide.svg for the problem (or alternatively http://www.codedread.com/dragtest.svg which shows the same effect). You see an object, which can be dragged around the screen holding the LH button down. It shows up best on a slow cpu (which is what I have got) because it is essentially a timing problem.

So drag it swiftly across the screen, corner to corner, and hold it stationary at the far end (you can let go the button now).

Under Firefox, AFAICS, the 'onmousemove' event happens, and your javascript function can see the (x,y) coordinates where the event happened (maybe it is a third way across the screen by this time). Your function does whatever it does (e.g. moves the object), and by the time it is finished your cursor is in the far corner and _stationary_. So there is never a second 'onmousemove' event, and the object never gets moved to its final destination (well, on a fast-enough CPU it might catch you before you had stopped moving the mouse, but even then it can still be fooled).

Using Opera OTOH (or IE I believe) it remembers where the movement had stopped, and continues sending 'onmousemove' events until you have caught the final coordinates. So the object get moved the whole way (eventually).

I think this is really a bug or misfeature in Firefox, but whether that is so or not, I would still like to hear how I can workaround it. The problem is that there is no way to ask whether the mouse is up or down at any instant - all you can do is invent an up/down variable yourself which is set/unset by onmouseup[down] events. | tried a "while myup/down is still down keep looking for those (x,y) coordinates" but that gave me a permanent loop which I could not get out of even by pushing and releasing the button. So what else can I do?

See http://home.clerew.man.ac.uk:7777/web/quickslide.svg for the problem (or alternatively http://www.codedread.com/dragtest.svg which shows the same effect). You see an object, which can be dragged around the screen holding the LH button down. It shows up best on a slow cpu (which is what I have got) because it is essentially a timing problem. So drag it swiftly across the screen, corner to corner, and hold it stationary at the far end (you can let go the button now). Under Firefox, AFAICS, the 'onmousemove' event happens, and your javascript function can see the (x,y) coordinates where the event happened (maybe it is a third way across the screen by this time). Your function does whatever it does (e.g. moves the object), and by the time it is finished your cursor is in the far corner and _stationary_. So there is never a second 'onmousemove' event, and the object never gets moved to its final destination (well, on a fast-enough CPU it might catch you before you had stopped moving the mouse, but even then it can still be fooled). Using Opera OTOH (or IE I believe) it remembers where the movement had stopped, and continues sending 'onmousemove' events until you have caught the final coordinates. So the object get moved the whole way (eventually). I think this is really a bug or misfeature in Firefox, but whether that is so or not, I would still like to hear how I can workaround it. The problem is that there is no way to ask whether the mouse is up or down at any instant - all you can do is invent an up/down variable yourself which is set/unset by onmouseup[down] events. | tried a "while myup/down is still down keep looking for those (x,y) coordinates" but that gave me a permanent loop which I could not get out of even by pushing and releasing the button. So what else can I do?

Toate răspunsurile (2)

more options

A good place to ask advice about web development is at the mozillaZine Web Development/Standards Evangelism forum.
The helpers at that forum are more knowledgeable about web development issues.
You need to register at the mozillaZine forum site in order to post at that forum.

See http://forums.mozillazine.org/viewforum.php?f=25

more options

Thanks. I have done that.