jQuery Awesome Mousehold Event
Anyway, traditional applications have 'spinners' that make numbers or items go up and down (I'm working on that too). This jQuery plugin adds the missing 'repeat' event.
The 'repeat' is when you keep a key pressed down and it keeps printing the character, or you keep the mouse button pressed down and it keeps firing the click event.
The plugin works by setting a 'mousedown' event and keeps firing the function at the given interval until the 'mouseup' event or the mouse moves off the element.
This last logic is because if it wasn't in place, the function specified would keep firing (since the mouse up event fired, but not on the element we set it on).
js code:
running = true; $(function(){ $('div.pipTicker').each(function(){ var pipDiv = this; $('a', pipDiv).each(function(){ var href = $(this).href() $(this).mousehold(function(i) { var pip = parseFloat($('input#pip').val()) var hrefPip = parseFloat(href.match(/spin=([\-0-9\.]+)/)[1]) var dp = parseInt($('input#dp').val()) if (hrefPip < 0) pip *= -1 if (!pip) pip = hrefPip var s = new stepper(pip, dp) /* console.log("hit number", i)*/ var v = parseFloat($('input', pipDiv).val()) $('input', pipDiv).val(s.step(v)) }) }) }) $('div.pipTicker a').click(function(){ return false }) })
You might also like
Tags
accordion accordion menu animation navigation animation navigation menu carousel checkbox inputs css3 css3 menu css3 navigation date picker dialog drag drop drop down menu drop down navigation menu elastic navigation form form validation gallery glide navigation horizontal navigation menu hover effect image gallery image hover image lightbox image scroller image slideshow multi-level navigation menus rating select dependent select list slide image slider menu stylish form table tabs text effect text scroller tooltips tree menu vertical navigation menu