RevealTrans Filter - Page 3
August 23, 2002
First Things First: This is a DHTML event; thus you must be
running MSIE4.0+ to see the effect. However, browsers that do not
understand DHTML will happily ignore the commands without throwing
errors, so feel free to use them at will.
You can find this tutorial, and all of its examples, online at
http://www.htmlgoodies.com/beyond/revealTransFilter.html.
You can download just the examples at
http://www.htmlgoodies.com/wpg/.
Do you want a cool effect? Dig this! Figure 3.4 shows what this
tutorial teaches you. Notice that the button says to click it for
the image to go away. I clicked it and then captured the image as
the image was disappearing. Inside of two seconds, it was gone.
Really!
No eggs, thanks. . .
Better yet, you can also set it so that the image comes back.
What you're seeing there is the revealTrans() filter at work.
Two separate JavaScripts are using the filter to make a SPAN
disappear and then reappear. I'll show you the first one and then
explain the second one, but only quickly. (It's just like the first
one only backward. )
Make It Disappear
As I said previously, the image, "eggs.gif", itself doesn't
disappear. The SPAN surrounding the image disappears. The image
just goes with it. So, let's start with the SPAN and its image.
The code looks like this:
<INPUT TYPE="button" VALUE="Go Away!" onClick="go();">
<SPAN ID=Egg1 Style="Visibility:visible;
Filter:revealTrans(duration=2);width:179;height:110">
<IMG SRC="eggs.gif">
</SPAN>
The first line is a form button with the text "Go Away!" The
button is there to act as a trigger for the function "go()". When
clicked, the function fires.
The code is a basic SPAN surrounding the image flag displaying
the eggs.gif. A NAME, Egg1, is given to the SPAN. That links it to
the next JavaScript covered in the next paragraph. Also, inside
the SPAN are some Style Sheet commands and the filter. Note that
the visibility of the SPAN is set to "visible". That changes in
the next script. Then comes the Filter:revealTrans(duration=2).
You can probably guess that the 2 means two seconds for the effect.
Then the height and width of the image are given so that the SPAN
fits it perfectly.
Okay. Got the SPAN? Good. Now here is the script that does the
dirty work:
<SCRIPT LANGUAGE="javascript">
function go() {
Egg1.filters[0].Apply();
if (Egg1.style.visibility == "visible")
{
Egg1.style.visibility = "hidden";
Egg1.filters.revealTrans.transition=12;
}
else
{
Egg1.style.visibility = "visible";
Egg1.filters[0].transition=12;
}
Egg1.filters[0].Play();
}
</SCRIPT>
The script is pretty straightforward. When the function go() is
triggered, the filter in Egg1 is applied. Remember that Egg1 is
the SPAN. We gave it that name in the first script.
Then, if Egg1 is visible, set its value to "hidden" using
transition number 12. Otherwise, make the SPAN Egg1 visible
by using transition number 12.
Then play the transition! There's nothing to it!
Doing It Through Layers - Page 2
Beyond HTML Goodies
Transition Numbers - Page 4
|