Skip to content

Instantly share code, notes, and snippets.

@cmcculloh
Created September 14, 2012 02:43
Show Gist options
  • Save cmcculloh/3719497 to your computer and use it in GitHub Desktop.
Save cmcculloh/3719497 to your computer and use it in GitHub Desktop.
refactored slider code
//SPOTLIGHT SLIDER LAYOUT 3
jQuery("#slider3 > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", <?php echo $con_spotlight_duration; ?>000, false);
var rotateHoverHandler = {
hoveredOver: false,
stopSlider: false,
isRotating: true,
hoverOver: function(){
jQuery("#slider3 > ul").tabs("rotate", null, false);
rotateHoverHandler.hoveredOver = true;
},
hoverOut: function(){
rotateHoverHandler.hoveredOver = false;
rotateHoverHandler.tryToRotate();
},
tryToRotate: function(){
if(!rotateHoverHandler.isRotating && !rotateHoverHandler.hoveredOver){
rotateHoverHandler.isRotating = true;
jQuery("#slider3 > ul").tabs("rotate", <?php echo $con_spotlight_duration; ?>000, false);
}else{
rotateHoverHandler.isRotating = false;
jQuery("#slider3 > ul").tabs("rotate", null, false);//clear the rotate again, just in case
}
}
}
jQuery("#slider3-wrapper").hover(rotateHoverHandler.hoverOver, rotateHoverHandler.hoverOut);
/*start the timer over if they click, because it means they are interacting with something other
than the video. So, once the video is over, they might click on the next tab in the slider and then
hover off, meaning they want the slider to rotate.*/
document.body.onmousedown = function(){
rotateHoverHandler.tryToRotate();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment