Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #32134
| From | Martin Honnen <martin.honnen@gmx.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Empty function |
| Date | 2017-01-08 08:29 +0100 |
| Organization | Liberty Development |
| Message-ID | <o4sppl$ub7$1@news.albasani.net> (permalink) |
| References | <UPqdnRaDtOBAT-zFnZ2dnUU7-RHNnZ2d@westnet.com.au> |
On 08.01.2017 06:49, Andrew Poulos wrote:
> var Drag = {
> obj : null,
> init: function(o) {
> o.onmousedown = Drag.start;
> o.root.onDrag = function() {}; //--> what does this line do?
> },
> start: function(e) {
> document.onmousemove = Drag.drag;
> document.onmouseup = Drag.end;
> return false;
> },
> drag: function(e) {
> Drag.obj.root.onDrag(nx, ny);
> return false;
> },
> end: function() {
> document.onmousemove = null;
> document.onmouseup = null;
> }
> };
>
> What I don't follow is what the line
> o.root.onDrag = function() {};
> is doing. If I comment the line out the code "doesn't work". What's the
> purpose of setting an event to an empty function?
Is that the complete code? I don't see any nx or ny variables declared
anywhere that are used in
Drag.obj.root.onDrag(nx, ny)
so I guess somewhere else the onDrag function is assigned or can be
assigned a handler that does have a body doing something.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Empty function Andrew Poulos <ap_prog@hotmail.com> - 2017-01-08 16:49 +1100
Re: Empty function Martin Honnen <martin.honnen@gmx.de> - 2017-01-08 08:29 +0100
Re: Empty function Andrew Poulos <ap_prog@hotmail.com> - 2017-01-08 20:05 +1100
Re: Empty function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-08 23:40 +0100
Re: Empty function Andrew Poulos <ap_prog@hotmail.com> - 2017-01-09 10:47 +1100
Re: Empty function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-09 01:10 +0100
Re: Empty function JJ <jj4public@vfemail.net> - 2017-01-08 20:53 +0700
Re: Empty function "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-08 10:02 -0800
Re: Empty function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-08 23:21 +0100
csiph-web