M
maya
I'm trying to implement a drag-n-drop script, found here..
http://cwdjr.net/test/newDrag.html
but it doesn't work quite the way I want it to (div to drag-n-drop moves
down the window when I first click on it..)
I'm having a hard time dealing with the code because I don't understand
some things about it..
first of all, in this script the function that does the drag-n-drop is
called thus:
return dragImg(this,event)
but function is declared thus:
function dragImg(div,evt,how) {
what is the 'how' for ?? it's not passed to function from function
call.. if I take it out from function declaration get error that 'how'
is undefined, but where IS it defined in this script (I mean what does
it evaluate to before code inside function starts running (I tested with
an alert in first line of function, it prints 'undefined', so I really
don't get this...)
also can someone pls explain syntax of these var declarations? (rather,
they're var initializations, right?)
how = how || "relative";
var mx = evt.pageX || evt.clientX + root.scrollLeft;
I've never seen vars initialized like this in JS (or any other language
for that matter) and can't look this up because don't even know what to
search for....
thank you very much...
http://cwdjr.net/test/newDrag.html
but it doesn't work quite the way I want it to (div to drag-n-drop moves
down the window when I first click on it..)
I'm having a hard time dealing with the code because I don't understand
some things about it..
first of all, in this script the function that does the drag-n-drop is
called thus:
return dragImg(this,event)
but function is declared thus:
function dragImg(div,evt,how) {
what is the 'how' for ?? it's not passed to function from function
call.. if I take it out from function declaration get error that 'how'
is undefined, but where IS it defined in this script (I mean what does
it evaluate to before code inside function starts running (I tested with
an alert in first line of function, it prints 'undefined', so I really
don't get this...)
also can someone pls explain syntax of these var declarations? (rather,
they're var initializations, right?)
how = how || "relative";
var mx = evt.pageX || evt.clientX + root.scrollLeft;
I've never seen vars initialized like this in JS (or any other language
for that matter) and can't look this up because don't even know what to
search for....
thank you very much...