-(unichar) fn: (unichar)n{ return n ^ 0xFFFF004B == 0? n : [self fn:(n-0x1)]}


jCarousel Lite Mouse Hover Event Improvement

jCarousel Lite is a fantastic jQuery plug-in to display photo gallery. You can have a look at the demo at: http://www.gmarwaha.com/jquery/jcarousellite/#demo

On this demo, the photo gallery will only scroll left or right when you click on the left arrow and right arrow. On jCarousel’s document, we can initialize the carousel start scrolling when the page finishes loading by specify the option: auto

$(".slider").jCarouselLite({
visible: 4,
<strong>auto: true</strong>,
speed: 2000
});

What if I want it to stop when my mouse hover on any of the images? Oh, jCarousel does not originally handle mouse hover event. Well, DIY time.

Firstly, download the carousel original source code from the official website

open that file (jcarousellite_1.0.1.js)

Second, add a code block between line “function go(to){” (about line 292):

//&lt;!--add by koumei
var isMouseOver = false;
$(this).mouseover(function(){
isMouseOver = true;
}).mouseout(function(){
isMouseOver = false;
});
//add by koumei--&gt;
function go(to) {
...
...

Third, modify function go: (around line 293)

Change "if(!running)" to "if(!running &amp;&amp; !isMouseOver)"

Fourth, DONE.

Quite simple, I hope the author will consider this function to the next release. :-)

You can also download my modified version and the demo at:

http://koumei.net/download/carousel-demo.zip


8 Responses to “jCarousel Lite Mouse Hover Event Improvement”

  1. Lo says:

    Thanks for sharing :)

  2. mrgreenfur says:

    This works! Thanks.

  3. Alex Leak says:

    Hey realy u post very nice information.. i like this post…
    thanks its use for me…

  4. Moazzam says:

    Thanks!!!,

    I m a asp.net programmer. one of my customer required this feature on his website where jCarouselLite is already used. This really worked…

  5. Tom bikinurse says:

    You are a genious this post as helped me a great deal

  6. Tung tran says:

    Great. Thank so much.

  7. Abhishek says:

    hi this is very helpful to me thanks!!!!!!!!!!!!!1

  8. Ali Fareedi says:

    Its awesome , Thank you so much great work :)

Leave a Reply

Profile