views:

923

answers:

2

I would be grateful if someone can help with with some javascript code. I have a content slider which can be found here:-

link text

This works fine but I would like to change the following code so that it pauses on hover. Any ideas?

<script type="text/javascript">
$(document).ready(function(){
 $("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
});

Thanks in advance of your help.

Kind regards

Jonathan

+1  A: 

What you're looking for is the stop method. Something along the lines of:

$(".ui-tabs-panel").mouseover(function(e) {
    if($(this).is(':animated')) {
        $(this).stop();
    }
});
karim79
Hi Karim Thanks for your help. Can you help with the syntax in the context of my existing code please- not sure where or how to add your code:-<script type="text/javascript"> $(document).ready(function(){ $("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true); });</script>
Jonathan Lyon
@Jonathan Lyon - from looking at your page, I gather that the animations happen on the divs with class=".ui-tabs-panel". Try adding the above event handler after the line where you call .tabs(...
karim79
i tried that and it doesn't seem to work. The main image goes blank when hovered. If you could spell it out for me with my code example above it would be really helpful.
Jonathan Lyon
@Jonathan Lyon - maybe try it without the if condition, that is just $(this).stop if it helps
karim79
A: 

Looks like you're using jQuery.UI. Here's how i've done it in the past using the same library (courtesy of this tutorial):

$(document).ready(function(){  
    $("#featured").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);  
    $("#featured").hover(  
        function() {  
            $("#featured").tabs("rotate",0,true);  
        },  
        function() {  
            $("#featured").tabs("rotate",5000,true);  
        }  
    );  
});
richeym
I originally tried that and it works only if you do not click on the thumbial text.It behaves extremely erractically if you click on any of the thumbnails a few times.It either stops working or starts moving really quickly and out of synch.http://metalbuildinggroup.ca/contentslider/
Jonathan Lyon