john_woo wrote on 29 dec 2007 in comp.lang.javascript:
> Hi,
>
> If what I want from the on_mouse_move function is, trigger another
> function in two case:
> 1. when the mouse holds at same position for 1 second;
With each mousmove detected start a setTimeout delay of 1 sec, after
resetting the last one.
If the delay fully times out, start your function.
> 2. when the mouse fully stop[s?];
What is that, you will have to define that, no trigger for how long,
three days perhaps?
It is the same as above.
> in other cases (when mouse keeps moving) don't trigger that function.
>
> Can any one tell how to implement this?
Yes, it is elementary.

Signature
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
john_woo - 30 Dec 2007 14:57 GMT
> john_woo wrote on 29 dec 2007 in comp.lang.javascript:
>
[quoted text clipped - 8 lines]
>
> If the delay fully times out, start your function.
you won't be able to tell during that 1 second, whether the mouse
stays in same position (namely X/Y never changed, the case that mouse
moves away and move back doesn't count);
The question is clear that triggering another function only when the
mouse stays for 1 second.
Evertjan. - 30 Dec 2007 16:37 GMT
john_woo wrote on 30 dec 2007 in comp.lang.javascript:
>> john_woo wrote on 29 dec 2007 in comp.lang.javascript:
>>
[quoted text clipped - 12 lines]
> stays in same position (namely X/Y never changed, the case that mouse
> moves away and move back doesn't count);
Wrong, the mouse has moved if an onmousemove event was triggered.
Testing where the mouse is in x/y is not necessary nor usefull.
<http://www.w3schools.com/jsref/jsref_onmousemove.asp>
> The question is clear that triggering another function only when the
> mouse stays for 1 second.
Indeed.

Signature
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
john_woo - 30 Dec 2007 17:18 GMT
On Dec 30, 11:37 am, "Evertjan." <exjxw.hannivo...@interxnl.net>
wrote:
> john_woo wrote on 30 dec 2007 in comp.lang.javascript:
>
[quoted text clipped - 19 lines]
>
> <http://www.w3schools.com/jsref/jsref_onmousemove.asp>
The question is not about the on_mouse_move definition. say mouse
moves from
A -> B (move slowly) -> C (here stop for 1 second then continue to
move) -> D, and fully stops at D
thus the movement triggers event at A, B and C. my question was, I
wanted to trigger another function only when the mouse at C, not at B
nor D;
the setTimeout is used to delay action, regardless of whether mouse
stop 1 second then move again or keep moving without stop.
John
Evertjan. - 30 Dec 2007 18:07 GMT
john_woo wrote on 30 dec 2007 in comp.lang.javascript:
> On Dec 30, 11:37 am, "Evertjan." <exjxw.hannivo...@interxnl.net>
> wrote:
[quoted text clipped - 33 lines]
> wanted to trigger another function only when the mouse at C, not at B
> nor D;
No that was not the Q.
The Q was:
>> >> > 1. when the mouse holds at same position for 1 second;
> the setTimeout is used to delay action, regardless of whether mouse
> stop 1 second then move again or keep moving without stop.
No, you are looking at my programming advice the wrong way.
I'll refrase:
Every time the mouse moves, the setTimeout is reset and restarted.
Only if there is no movement for one second, setTimeout times out and
your function is executed.

Signature
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)