This should work for you:
http://yura.thinkweb2.com/playground/state-notifier/

On Thu, 15 Nov 2007 07:00:12 -0800 (PST)
Matt Foster <[EMAIL PROTECTED]> wrote:

> 
> var listener = function(e){
> 
> 
>               //do something cool like a mouse trail!
> 
> 
>              clearTimeout(this.timer);  //so you don't get tripped up
> if the user is hyper.
>              this.timer = setTimeout(function(){
>  
> Event.stopObserving("target", "mouseover", listener);
>                                                 }, 2000);
> 
> 
> }
> 
> 
> Event.observe("target", "mouseover", listener);
> 
> 
> On Nov 15, 9:09 am, Gregory Seidman <gsslist
> [EMAIL PROTECTED]> wrote:
> > On Thu, Nov 15, 2007 at 10:08:22AM +0100, Jean-Philippe Encausse
> > wrote:
> >
> > > Hi,
> > > Is there a way to bind an Event on Mouse Waiting for a given time
> > > anywhere in the page ?
> >
> > > I mean:
> > > the mouse move, stop, move, stop, 2 seconds => Event, move, stop,
> > > clic, move, stop, 2 seconds => Event, ...
> >
> > > I think it is possible to code this behavior with timeout
> > > stoped/starts but it seems a bit complicated ...
> > > Does anybody has already did that ?
> >
> > I don't know of any existing implementation, but it's an
> > interesting idea. All you should need is to observe the various
> > mouse events on the page and a timeout, as you said. Maybe
> > something like:
> >
> > function(idleTime) {
> >   var currentTimeout = null;
> >   var fireIdle = function() {
> >     currentTimeout = null;
> >     $(document).fire('mouse:idle');
> >   };
> >   var resetTimeout = function() {
> >     if (currentTimeout) clearTimeout(currentTimeout);
> >     currentTimeout = setTimeout(fireIdle, idleTime);
> >   };
> >   $w('mouseDown mouseMove ...').each(function(evt) {
> >     Event.observe(document, evt, resetTimeout); });
> >
> > }(2000);
> >
> > I didn't bother putting all the mouse events in the list, I'm not
> > 100% certain I'm using the fire() method properly, and I just coded
> > it off the cuff with no testing, but there isn't much more to it.
> > With that, all you need to do is observe document's mouse:idle
> > synthetic event. Note that this depends on Prototype 1.6.
> >
> > > Regards,
> > > Jp
> >
> > --Greg
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google
> Groups "Ruby on Rails: Spinoffs" group. To post to this group, send
> email to [email protected] To unsubscribe from
> this group, send email to
> [EMAIL PROTECTED] For more options,
> visit this group at
> http://groups.google.com/group/rubyonrails-spinoffs?hl=en
> -~----------~----~----~----~------~----~------~--~---
> 


-- 
Julio Carlos Menéndez
GNU/Linux User #403551
http://deltha.uh.cu/~juliocarlos

Attachment: signature.asc
Description: PGP signature

Reply via email to