javascript - Add pause on hover to jQuery -
can assist me in trying pause on hover working example. need following.
- pause interval on hover
- highlight item hovered on
- on hover out resume rotate
code (fiddle demo):
var $f = $('ul').find('.frame'); function recursive(i) { $f.removeclass('showing').eq(i).addclass('showing'); settimeout(function () { recursive(++i % $f.length) }, 1000); } recursive(0);
you might need tweak bit fit requirements. idea clear interval on mouse on , resume recursion on mouseout & keep reference count.
var $f = $('ul').find('.frame'), timeout, count; function recursive(i) { count = i; $f.removeclass('showing').eq(i).addclass('showing'); timeout = settimeout(function () { recursive(++i % $f.length) }, 1000); } $('ul li').hover(function(){ cleartimeout(timeout); }); $('ul li').mouseout(function(){ recursive(count); }); recursive(0);
Comments
Post a Comment