Randy Webb wrote:
RobG said the following on 7/27/2006 1:42 AM:
[...]
Wont that create a deeply recursive function?
Absolutely <g>
Firefox seems to allow 1,000 recursions before a 'too much recursion'
error occurs. Maybe there's a setting somewhere to change that... ;-p
If the mouse button is held down for some time, it will likley cause a problem.
It's not "likely", rather its pretty dependable.
And pretty quick - a simple script does it in less than 10ms.
It seems to me that whatever is kicked-off by the mousedown event hogs
the one and only JS thread (in Firefox and IE at least), so the mouseup
event is qued and can't interup the process started by the mousedown.
To 'work', the script must come up for air to see if some other event
wants to do something, setTimeout (or maybe setInterval) seem to be the
only way to do that.
It may be better to use setTimeout onmousedown, then cancel it
onmouseup, e.g.:
Depending on what you want. At 13ms timeout, you can only execute it
once every 13ms, whereas with the recursion it happens as fast as the
processor can process the script.
If the minimum interval is 13ms (or whatever, I guess it's
implementation dependent) then that is as fast as you can do it. Other
choices are to either wait for a 'too much recursion' error or a 'this
script is taking too much time' message.
Maybe they suit the OP better :-)
--
Rob