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 ? Regards, Jp -- Jean-Philippe Encausse - Veille / R&D Jalios SA Jp [at] encausse.net - http://www.encausse.com - http://www.jalias.com GTalk: jp.encausse [at] gmail.com - SMS: sms [at] jp.encausse.net Mob: +33 6 82 12 56 99 - Job: +33 1 39 23 92 83 - Tel: +33 1 39 18 90 15 Do it Once, Use it Twice ~ Do it Twice, Make It Once --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
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 +protot...-dNXPQ6k9rNiG6BJUYyje5axOck334EZe@public.gmane.org> 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
This should work for you: http://yura.thinkweb2.com/playground/state-notifier/ On Thu, 15 Nov 2007 07:00:12 -0800 (PST) Matt Foster <mattfoster01-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 > +protot...-dNXPQ6k9rNiG6BJUYyje5axOck334EZe@public.gmane.org> 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from > this group, send email to > rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 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
That''s absolutly great ! That''s exactly what i''m looking for :-) Thanks to every body, many thanks to Julio Carlos Menéndez On Nov 15, 2007 4:05 PM, Julio Carlos Menéndez <juliocarlos-70/qqqu8D0M@public.gmane.org> wrote:> This should work for you: > http://yura.thinkweb2.com/playground/state-notifier/ > > > On Thu, 15 Nov 2007 07:00:12 -0800 (PST) > Matt Foster <mattfoster01-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 > > +protot...-dNXPQ6k9rNiG6BJUYyje5axOck334EZe@public.gmane.org> 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 > > > > > > > -- > Julio Carlos Menéndez > GNU/Linux User #403551 > http://deltha.uh.cu/~juliocarlos >-- Jean-Philippe Encausse - Veille / R&D Jalios SA Jp [at] encausse.net - http://www.encausse.com - http://www.jalias.com GTalk: jp.encausse [at] gmail.com - SMS: sms [at] jp.encausse.net Mob: +33 6 82 12 56 99 - Job: +33 1 39 23 92 83 - Tel: +33 1 39 18 90 15 Do it Once, Use it Twice ~ Do it Twice, Make It Once --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---