Drag'n'Drop code wanted

D

Dr J R Stockton

I can now revolve the Universe by using my mouse :
see <http://www.merlyn.demon.co.uk/astron-5.htm#FS>.

But all I do is to turn it by +1 or -1 degree at a time, according to
whether the mouse moves to the right or to the left :
Rag.onmousedown = function (e) { Doon = true }
Rag.onmouseup = function (e) { Doon = false }
Rag.onmousemove = function (e) { if (!Doon) return
e = e || window.event
var X = e.clientX
var Q = document.forms[0].Revolve
Q.value = +Q.value + (XXX < X ? +1 : -1)
Draw()
XXX = X }
(tested in FF 3.0.15 only)

I have not yet been able to discover how to convert (cross-browser)
e.clientX and e.clientY (or other) values to X and Y co-ordinates with
respect to the centre of the canvas (which is of known size, so the
corner will do).

With that it should be easy enough to make the Universe rotate as if the
mouse, when down, were holding on to a spoke of the circle but able to
slide along it.

Ant suggestions? Working ones?
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]
rlyn.invalid>, Thu, 10 Mar 2011 23:44:00, Dr J R Stockton
I can now revolve the Universe by using my mouse :
see <http://www.merlyn.demon.co.uk/astron-5.htm#FS>.

But all I do is to turn it by +1 or -1 degree at a time, according to
whether the mouse moves to the right or to the left :
Rag.onmousedown = function (e) { Doon = true }
Rag.onmouseup = function (e) { Doon = false }
Rag.onmousemove = function (e) { if (!Doon) return
e = e || window.event
var X = e.clientX
var Q = document.forms[0].Revolve
Q.value = +Q.value + (XXX < X ? +1 : -1)
Draw()
XXX = X }
(tested in FF 3.0.15 only)

I have not yet been able to discover how to convert (cross-browser)
e.clientX and e.clientY (or other) values to X and Y co-ordinates with
respect to the centre of the canvas (which is of known size, so the
corner will do).

With that it should be easy enough to make the Universe rotate as if the
mouse, when down, were holding on to a spoke of the circle but able to
slide along it.

Ant suggestions? Working ones?
Any


There having been no response, I have implemented a work-round. It
works in Win XP sp3 with FF 3.6.15, Op 10.01, Sf 5.0.4, Cr 10.0. The
context does not allow it in IE 8 (no canvas, so nothing to move),

But can someone with IE9, which should have canvas, please test
<http://www.merlyn.demon.co.uk/astron-5.htm#FS> drag'n'drop in both
modes, AFTER reading section "Drag and Drop" near the end of the page?
And, if necessary, suggest a tested fix? How about in a non-PC?
 
D

Dr J R Stockton

On 17/03/2011 10:40 AM, Dr J R Stockton wrote:

In IE9 it seems to behave different from how its meant to.

No double-click, I can drag the map.

Hoped for, but not positively intended. Unsupported, but should be
reliable.

With initial double-click and then a click on the map I can rotate the
map by dragging it.

That should happen when dragging the white circle. Dragging the
greenish square with the cursor outside the circle should drag the
contents of the square, including the circle, without rotation.

I don't detect the circle itself, just rotate the rotatables for drags
within a circle-radius of where the centre ought to be.

So it seems that nothing additional is needed for IE9. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top