Here is the javascript function in which I am trying to bring about a sliding effect.
What I want is, upon clicking the right button (green coloured button), the sliding effect should replace the tab with another tab, all are block elements.
However, the effect is not working & I am sure I am doing something wrong with the jquery code. (the fade effect works fine on the left button (orange coloured button).
function activateRightTab()
{
var eTabIndDiv = document.getElementById ("feature_tabs_indicators").children[0];
var iIndsCount = eTabIndDiv.childNodes[1].children.length;
var direction = "right";
if (iActiveNo < iTabsCount - 1 && iActiveNo >= 0)
{
iActiveNo = iActiveNo + 1;
if (iActiveNo != 1 || iActiveNo != 0)
{
$(eTabsDiv.children[iActiveNo - 1]).stop() .animate({"left" : "300px"}, 500);
eTabsDiv.children[iActiveNo - 1].style.display = "none";
eTabIndDiv.children[iActiveNo - 1].style.backgroundColor = "rgb(122,121,198)";
}
**$(eTabsDiv.children[iActiveNo]).stop() .animate({"left" : "300px"}, 500);**
eTabsDiv.children[iActiveNo].style.display = "block";
eTabIndDiv.children[iActiveNo].style.backgroundColor = "rgb(0,100,200)";
}
activateFeaturesContainer(direction);
return iActiveNo;
}
Here is the complete code (rather long) but it gives an idea of the effect I am trying to achieve.
I think what you want is something like this: http://www.apple.com/macbookair/
For that, you first have to give
div#featuresanoverflow: hidden, otherwise, the content is not hidden while traveling to the left/coming in from the right.You then have to position the new
uljust outside the the viewable area and make it visible, otherwise the new content doesn’t come in from the right (assuming it is what you want). In your case, you have to setleft: 292; display: block. Now, you select both the old and newuland apply an animation ofleft: '-=292px'. You then hide the old one. That should about do it.Notes:
Because of
overflow: hidden, you have to set a clearly defined height.height: autohas no meaning anymore since the div does not grow with its content anymore. Ideally, you adjust the height via JS to its children.I am working with the static values in your code to make a simple explanation. If
div#featuresever changes width, you have to change it in the code too. For better maintenance, I’d suggest you get the width ofdiv#featureswith.outerWidth(), and base your animation off of that value