Thursday, 7 February 2008

Effect appear (fade-in) using Scriptaculous

Scriptaculous Fade effect is one of my favorite effects of this framework and in this post I want to use it to implement a Digg-line sign-in bar.

My friend Ivan asked to me how to implement the same Digg-like fade-in effect which you can see when you click on the Login link on the Digg topbar. This is very simple using Scriptaculous and toggle effect with only few lines of HTML code.


Download this tutorial

Step 1: Download Scriptaculous Framework
Before to start, you have to download scriptaculous framework here and add a link to prototype.js and scriptaculous.js in the <head> tag of your page:

<script src="scriptaculous/lib/prototype.js" type="text/javascript"></script>
<script src="scriptaculous/src/scriptaculous.js" type="text/javascript"></script>


Step 2: HTML code
HTML code is very simple

<div id="login" style="display:none;">
Email <input name="email" type="text" /> Password <input name="password" type="text" /></div>
<a href="#" onclick="Effect.toggle('login','appear'); return false;">Login</a>

Effect.toggle() function takes as input two parameters: layer ID (in this case "login") and type of effect (in this case "appear" to simulate fade-in effect).

Download this tutorial

No comments:

Post a Comment