[jQuery] Re: Repeating a function call on hover/mouseover/etc

2008-09-02 Thread Leanan

Thanks for the answer.  Unfortunately it doesn't seem to want to play
well with the plugin and I didn't want to have to do significant
changes.

The plugin I'm using is jquery.scrollable.js.

Anyone know of a nice scrolling plugin that already has built in to it
the ability to continue scrolling when hovering over the "next" nav
item?  All the scrolling plugins I find use either timers or clicks.
I haven't dug into all their code yet; I don't mind doing minor
changes to the plugin.  The keyword here being: Minor. (couple of
lines)

On Aug 29, 5:32 pm, micah <[EMAIL PROTECTED]> wrote:
> one way to approach what you're trying to do is with a simple
> setInterval (http://developer.mozilla.org/index.php?title=En/DOM/
> Window.setInterval), so that the parser has a bit of breathing room
> between calls to someFunc.
>
> if you just loop through, you're essentially saying "call someFunc as
> many times as you can, as fast as you can possibly call it", which
> isn't really cpu-friendly ;)
>
> try this instead:
>
> var int = null;
> $('#element').hover(function() {
>   int = setInterval(someFunc, 100);}, function() {
>
>   clearInterval(int);
>
> });
>
> -micah
>
> On Aug 29, 2:00 pm, Leanan <[EMAIL PROTECTED]> wrote:
>
> > Hey guys.
>
> > I've poured over the docs, and mouseover/hover/etc only trigger once.
> > I want it to continue to trigger a function while the element is
> > hovered.
>
> > I've tried:
>
> > $('#element').hover(function() {
> >   while(true) {
> >     someFunc;
> >   }
>
> > }, function() {});
>
> > Unfortunately, this screws things up.  The while loop hangs the
> > browser for a while before it finally throws the "this script has been
> > running too long" message.
>
> > I've tried looking at some of the scrolling plugins to see how they do
> > it but the only one I can find that seems to have this functionality
> > (do something while hovering over an element, in this case, continue
> > scrolling) has no documentation, and the examples do not explain how
> > to use the plugin, they merely show it working.  What little bit of
> > text is on the page is non-english and from the looks of it is little
> > more than headers anyway, so useless even if I translated it.
>
> > So, how should I go about continuing to trigger someFunc while I'm
> > hovered over a particular item on the page?


[jQuery] Re: Repeating a function call on hover/mouseover/etc

2008-08-29 Thread micah

one way to approach what you're trying to do is with a simple
setInterval (http://developer.mozilla.org/index.php?title=En/DOM/
Window.setInterval), so that the parser has a bit of breathing room
between calls to someFunc.

if you just loop through, you're essentially saying "call someFunc as
many times as you can, as fast as you can possibly call it", which
isn't really cpu-friendly ;)

try this instead:

var int = null;
$('#element').hover(function() {
  int = setInterval(someFunc, 100);
}, function() {
  clearInterval(int);
});

-micah

On Aug 29, 2:00 pm, Leanan <[EMAIL PROTECTED]> wrote:
> Hey guys.
>
> I've poured over the docs, and mouseover/hover/etc only trigger once.
> I want it to continue to trigger a function while the element is
> hovered.
>
> I've tried:
>
> $('#element').hover(function() {
>   while(true) {
>     someFunc;
>   }
>
> }, function() {});
>
> Unfortunately, this screws things up.  The while loop hangs the
> browser for a while before it finally throws the "this script has been
> running too long" message.
>
> I've tried looking at some of the scrolling plugins to see how they do
> it but the only one I can find that seems to have this functionality
> (do something while hovering over an element, in this case, continue
> scrolling) has no documentation, and the examples do not explain how
> to use the plugin, they merely show it working.  What little bit of
> text is on the page is non-english and from the looks of it is little
> more than headers anyway, so useless even if I translated it.
>
> So, how should I go about continuing to trigger someFunc while I'm
> hovered over a particular item on the page?