Created
September 22, 2010 12:03
-
-
Save bil-bas/591559 to your computer and use it in GitHub Desktop.
slideBulge function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// slideBulge function | |
// slides the top right menu bulge bg to the left/right to the requested position. | |
function slideBulge(currentPos, endPos) { | |
//stop the slideBulge function (if it is still looping) | |
clearTimeout(bulgeTimeout); | |
//set the jumpSize and jumpSpeed: | |
var jumpSize = 3; | |
var jumpSpeed = 10; | |
currentPos = parseInt(currentPos); | |
endPos = parseInt(endPos); | |
//if not already at endPos: | |
//(nb, remember we're going backwards (to the left) so slide if endPos is smaller) | |
var newPos = currentPos + (endPos > currentPos ? jumpSize : -jumpSize); | |
if ((newPos > currentPos && newPos >= endPos) || | |
(newPos < currentPos && newPos <= endPos)) { | |
newPos = endPos; | |
} else { | |
bulgeTimeout = setTimeout("slideBulge('"+newPos+"', '"+endPos+"')", jumpSpeed); | |
} | |
//make the bg position adjustment: | |
document.getElementById('navs').style.backgroundPosition = newPos + 'px bottom'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment