|
Help
CodingForums Partners
This is a
![]() |
|
| method | description |
| Duration | Sets/ retrieves the length of time in seconds the transition takes to complete. Attribute: duration. |
| Enabled | Boolean that sets or retrieves the state of the transition (either enable or disable it). Attribute: enabled. |
| status | Integer that returns the status of the transition:
|
| method | description |
| apply() | Saves the current state of the image to use the transition effect on. |
| play() | Invokes and plays the fade-in effect on the saved state of the image, fading to a new one. |
| stop() | Stops the transition from playing. |
The basic procedure to applying and playing the "Fade" filter on any object is very logical- first call apply() to save the current state of the object just before the filter is played, then use play() to play it! Here are two examples that should explain the whole concept nicely:
<script type="text/javascript">
function fadetoview(objname){
var objholder=document.getElementById(objname)
objholder.filters[0].apply()
objholder.style.visibility="visible"
objholder.filters[0].play()
}
</script>
<div id="sometext" style="visibility: hidden; width: 300px; font: normal
16px Arial;
filter:progid:DXImageTransform.Microsoft.Fade(duration=2)">JavaScript
kit</div>
<a href="javascript: fadetoview('sometext')">Fade text to view</a>
Lets break down the three lines of codes in red to explain in detail what the heck is going on.
The first line:
objholder.filters[0].apply()
accesses the "Fade" filter of the object and calls the apply() method to save the current object state (of being "hidden"). This is necessary so that IE knows the initial state of the object in which to fade the object using.
The second line
objholder.style.visibility="visible"
then tells IE the post state of the object we want it to be in after the Fade filter has been run.
And finally, the third lineobjholder.filters[0].play()
plays the Fade filter, thus creating the fade-in effect. The sequence of the three lines of code above is important relative to one another.
To fade from one object to another is really no different. The below example fades from one image to another:
<img src="image1.gif" id="someimage" border=0
style="filter:progid:DXImageTransform.Microsoft.Fade(duration=3)" width="97"
height="100" />
<form><input type="button" value="play >>"
onClick="fadeimg('someimage')"></form>
<script type="text/javascript">
function fadeimg(objname){
var objholder=document.getElementById(objname)
objholder.filters[0].apply()
objholder.src=src="image2.gif"
objholder.filters[0].play()
}
</script>
Here the only difference in that I set the object's src to a different image, switching from one object to another as the "Fade" filter is played.
You basically now know how to create a Fade-in image slideshow! Lets see how such a slideshow looks like.