<mySearch ⁄>
<mySnippets order="rand" ⁄>
<myContacts ⁄><email ⁄>
<windows live messenger ⁄>
<myCurriculum type="pdf" ⁄>
<myBlog show="last" ⁄>
<myNews show="rand" ⁄>
<myNews type="cat" ⁄>
<myQuote order="random" ⁄>O que importa antes de tudo é o momento presente. O momento presente é o criador do seu amanhã. Somos escravos do ontem, mas somos dono do nosso amanhã.
<myPhoto order="random" ⁄>
<myAdSense ⁄>
<myVisitorsMap ⁄>
#slidebar{ overflow: hidden; } #slidebar a{ display: block; background-repeat: no-repeat; outline: none; } #slidebar a.top{ background-image: url("bg.png"); z-index: 1; width: 125px; } #slidebar a.bottom{ background-image: url("bg2.png"); right: -160px; } #slidebar ul{ display: inline; list-style: none; } #slidebar, #slidebar a{ height: 83px; position: absolute; right: 0; top: 0; } #slidebar, #slidebar .bottom{ width: 160px; }
/** * Javascript SlideDown and Toggle Animations * * @return Function SlideMiddle * @return Function Toggle * @author pedrocorreia.net */ var DummyAnimations = function() { var /** * Get html element reference * * @param String Html ID * @return Object */ $ = function(o) { return document.getElementById(o) || null; }, /** * Get browser viewport height * * @return Int */ _view_height = function() { return window.innerHeight || document.documentElement.clientHeight || document.getElementsByTagName('body')[0].clientHeight; }, end _view_height /** * SlideDown object from top to center of browser window * * @param Object Html element * @param Int Value to increment * @param Int Speed * @param Int To position * @param Int Current position */ _Slide_Middle = function(o, step, speed, to, value) { var el = (typeof o === "object") ? o : $(o), value = value || 0, to = to || ((_view_height() - el.offsetHeight) / 2), /** * SlideDown Animation * * @param Int Current position */ _animate = function(value) { var self = arguments.callee, interval = setTimeout(function() { if (value < to) { value += step; el.style.top = value + "px"; self(value); } else { clearTimeout(interval); } }, speed); } (value); }, //end _Slide_Middle /** * Toggle * * @param Object Html element * @param Object Html element to toggle * @param Int Value to increment * @param Int Animation speed */ _ToggleBackground = function(o, o_bottom, step, speed) { var el = (typeof o === "object") ? o : $(o), el_bottom = (typeof o_bottom === "object") ? o_bottom : $(o_bottom), el_width = el.offsetWidth, el_bottom_width = el_bottom.offsetWidth, /** * Toggle animation * * @param Int Value to increment * @param Int Animation speed * @param Int Width * @param Object Element to hide * @param Object Element to show * @param Int Current position */ _animate = function(step, speed, _width, _el_hide, _el_show, value) { var value = value || 0, self = arguments.callee, interval = setTimeout(function() { if (value > -_width) { value -= step; _el_hide.style.right = value + "px"; _el_show.style.right = Math.abs(value) - _width + "px"; self(step, speed, _width, _el_hide, _el_show, value); } else { clearTimeout(interval); } }, speed); }; //end _ToggleBackground el.onmouseover = function(e) { e = e || window.event; _animate(step, speed, el_width, el, el_bottom); }; //end el.onmouseover el_bottom.onmouseout = function(e) { e = e || window.event; _animate(step, speed, el_bottom_width, el_bottom, el); }; //end el_bottom.onmouseout el.onclick = function(e) { e = e || window.event; if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } }; //end el.onclick el_bottom.onclick = function(e) { e = e || window.event; alert("Your code goes here...."); if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } }; }; //end el_bottom.onclick return { SlideMiddle: _Slide_Middle, Toggle: _ToggleBackground }; } (); //end DummyAnimations
window.onload = function() { // Slide Animation from Top to Middle DummyAnimations.SlideMiddle("slidebar", 25, 50); // Toggle pictures DummyAnimations.Toggle("top", "bottom", 5, 25); };
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Javascript SlideDown and Toggle Animations</title> <link rel="stylesheet" href="style.css" /> <script type="text/javascript" src="DummyAnimations.js"></script> <script type="text/javascript" src="Init.js"></script> </head> <body> <div id="slidebar"> <ul> <li><a href="#" class="top"></a></li> <li><a href="#" class="bottom"></a></li> </ul> </div> </body> </html>