N
N. Demos
Hello,
I'm working on a project in which I need to drag and drop an image
imbeded in a div frame {overflow: hidden}. I found this source code at
<http://www.youngpup.net/_projectDirectories/domdrag/dom-drag.js> which
I'm reading to figure out the subtlties of doing drag and drop with JS.
A simple implementation of this code is here:
<http://www.youngpup.net/_projectDirectories/domdrag/demos/ex2/index.html>
At this point I'm stuck on a one thing.
In the above source code (dom-drag.js) I generally understand what's
going on in the init() function, except the assignments on lines 36-38
36 o.root.onDragStart = new Function();
37 o.root.onDragEnd = new Function();
38 o.root.onDrag = new Function();
Why are these members being assigned empty functions? Later in the code
they are each called with coordinate pairs (x, y) as arguments.
In start() on line 47:
----------------------
47 o.root.onDragStart(x, y);
In drag() on line 101:
----------------------
101 Drag.obj.root.onDrag(nx, ny);
And in end() on line(s) 109, 110:
---------------------------------
109 Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style[Drag.obj.hmode
? "left" : "right"]),
110 parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
As there are no function bodys (that I can see), what is the use of
this? What is being executed by these calls? I'm obviously missing
something here. I took the source and commented out these function
definitions and calls and it doesn't seem to affect the functionality of
the example above.
Thanks for your time and attention.
Regards,
N. Demos
I'm working on a project in which I need to drag and drop an image
imbeded in a div frame {overflow: hidden}. I found this source code at
<http://www.youngpup.net/_projectDirectories/domdrag/dom-drag.js> which
I'm reading to figure out the subtlties of doing drag and drop with JS.
A simple implementation of this code is here:
<http://www.youngpup.net/_projectDirectories/domdrag/demos/ex2/index.html>
At this point I'm stuck on a one thing.
In the above source code (dom-drag.js) I generally understand what's
going on in the init() function, except the assignments on lines 36-38
36 o.root.onDragStart = new Function();
37 o.root.onDragEnd = new Function();
38 o.root.onDrag = new Function();
Why are these members being assigned empty functions? Later in the code
they are each called with coordinate pairs (x, y) as arguments.
In start() on line 47:
----------------------
47 o.root.onDragStart(x, y);
In drag() on line 101:
----------------------
101 Drag.obj.root.onDrag(nx, ny);
And in end() on line(s) 109, 110:
---------------------------------
109 Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style[Drag.obj.hmode
? "left" : "right"]),
110 parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
As there are no function bodys (that I can see), what is the use of
this? What is being executed by these calls? I'm obviously missing
something here. I took the source and commented out these function
definitions and calls and it doesn't seem to affect the functionality of
the example above.
Thanks for your time and attention.
Regards,
N. Demos