T
Tuxedo
I'd like to display an animation whereby images blend into each other, and
so have a question regarding the for-loop construct.
To start simply by a 2-image animation:
There is a 'div' containing the first and visible image.
<div id="container" style="width:300;height:250">
<img src="photo1.jpg" id="photo" width="300" height="250">
</div>
The background image of the div should become the second image by gradually
increasing the opacity of the foreground image.
Setting a background in the div while the first image is non-transparent,
can of course be done in CSS/JS as follows:
document.getElementById("container").style.backgroundImage="url(photo2.jpg)";
Therafter, I would like to gradually increase the opacity of the visible
photo from 0.1 (no opacity) to 0.0 (full opacity) thereby giving the
impression of the next image blending into view over the previous.
Setting opacity in JS/CSS is simply done, in the latest browsers, as
follows:
document.getElementById("photo").style.opacity=1.0; // no opacity
document.getElementById("photo").style.opacity=0.0; // full opacity
My question is, how can the loop be done, starting from no opacity to full
opacity, in for example 100 increments over a period of one second, by
setting/resetting the opacity and decimal values until the loop is complete?
Thanks in advance for any ideas.
so have a question regarding the for-loop construct.
To start simply by a 2-image animation:
There is a 'div' containing the first and visible image.
<div id="container" style="width:300;height:250">
<img src="photo1.jpg" id="photo" width="300" height="250">
</div>
The background image of the div should become the second image by gradually
increasing the opacity of the foreground image.
Setting a background in the div while the first image is non-transparent,
can of course be done in CSS/JS as follows:
document.getElementById("container").style.backgroundImage="url(photo2.jpg)";
Therafter, I would like to gradually increase the opacity of the visible
photo from 0.1 (no opacity) to 0.0 (full opacity) thereby giving the
impression of the next image blending into view over the previous.
Setting opacity in JS/CSS is simply done, in the latest browsers, as
follows:
document.getElementById("photo").style.opacity=1.0; // no opacity
document.getElementById("photo").style.opacity=0.0; // full opacity
My question is, how can the loop be done, starting from no opacity to full
opacity, in for example 100 increments over a period of one second, by
setting/resetting the opacity and decimal values until the loop is complete?
Thanks in advance for any ideas.