473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Weird double blink problem during fade in

Hi everybody!

I'm trying to put the icing on a cake
but I'm having one final problem.

The cake is actually a fadeIn function
that takes in input an element id(in my
case a <DIV> block) and a maximum opacity
parameter.

The element fades in correctly and reaches
the desired opacity. So we could say that
the function is doing the right thing.

Unfortunately, from a purely visual point
of view, -IF- the maximum opacity is set
to 1.0, there seem to be a brief "double flash"
just before the full opacity is reached.

That is: if I print out the values of the
opacity for each iteration of the function
I get what I would expect:

0.5, 0.6, 0.7, 0.8, 0.9, 1.0

but the following sequence of values
better describes -what I see-:

0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 0.0, 1.0

Notice that the length of the "0.0" flash
remains the same even if I increase the
milliseconds in the setTimeout() call.

It almost looks like some kind of browser
rendering problem rather than a scripting
issue.

Can anybody confirm my hypothesis?

Thanks in advance for your help!

Sincerely,

Manu
P.S. This is the code of the fade-in function I wrote,
together with its sibling fade-out, for completeness
and for anybody to use (although it's only Mozilla
compatible at this point...)

----
var fadeInTO, fadeOutTO;

function layer_fadeIn(layerName, maxOpacity)
{
clearTimeout(fadeOutTO);
myOpacity = document.getElementById(layerName).style.opacity;

if(myOpacity < maxOpacity)
{
myOpacity -= -0.10;
document.getElementById(layerName).style.opacity=m yOpacity;
var cmd2run="layer_fadeIn('"+layerName+"',"+maxOpacity +")";
var fadeSpeed=500;
fadeInTO=setTimeout(cmd2run,fadeSpeed);
}
}

function layer_fadeOut(layerName, maxTransparency)
{
clearTimeout(fadeInTO);
myOpacity = document.getElementById(layerName).style.opacity;

if(myOpacity > maxTransparency)
{
myOpacity -= 0.10;
document.getElementById(layerName).style.opacity=m yOpacity;

var
cmd2run="layer_fadeOut('"+layerName+"',"+maxTransp arency+")";
var fadeSpeed=10;
fadeOutTO=setTimeout(cmd2run,fadeSpeed);
}
}

Oct 23 '05 #1
2 1572
cjl
Manu3d:
...there seem to be a brief "double flash"
just before the full opacity is reached.


Check out the comment at the end of:
http://www.brainerror.net/scripts_js_blendtrans.php

The double flash occurs in Firefox, and it seems that a workaround
might be to never actually get to an opacity of 100.

I'll bet that most (all) people can't tell the difference between and
opacity of 99 and an opacity of 100.

-CJL

Oct 24 '05 #2
CJL, thanks for your reply. I tried the suggested method but
it didn't work. -However- it got me thinking, and I think it
helped me to find a bit of a "design" flaw in my fade-in
routine (which is why the method you pointed me to didn't work).
I therefore rewrote it and it's now working perfectly fine if we
close an eye on the fact that it reaches an opacity of "only"
0.999999. =)

This is the rewritten routine, for anybody to use:

var fadeInTO, fadeOutTO;

function layer_fadeIn(layerName,maxOpacity)
{
clearTimeout(fadeOutTO);
myOpacity = document.getElementById(layerName).style.opacity;

if(myOpacity < maxOpacity)
myOpacity -= -0.10;
else
return;

if(myOpacity < 1.0)
{
document.getElementById(layerName).style.opacity=m yOpacity;
}
else
{
document.getElementById(layerName).style.opacity=0 .999999;
return;
}

var cmd2run="layer_fadeIn('"+layerName+"',"+maxOpacity +")";
var fadeSpeed=10;
fadeInTO=setTimeout(cmd2run,fadeSpeed);

}

CJL, thanks for your help!

Ciao ciao!

Manu

Oct 24 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Ivan Weiss | last post by:
Hey guys I am trying to fade in a form using the following code: Public Class frmAbout Inherits System.Windows.Forms.Form Dim i As Integer 'Public Variable #Region The Windows Form code...
4
by: Chris Lieb | last post by:
Hi, I am writing a class in JavaScript to cause a repeating fade effect. The fade class takes care of the fading and the rgb class takes care of manipulating rgb values: function rgb(red,...
10
by: Sigmathaar | last post by:
Hi, I'm having some problems when using double linked lists, specially when it's up to the Blink an Flink pointers. Does anybody knows a good site or a book where they explain how to use them? ...
2
by: Bhan | last post by:
Hi, Can I get answers for the following: 1. Usage of Double Pointers during allocation memory.Heard that if memory is to be allocated by someone who is working on another module,then we...
2
by: Emil | last post by:
Hi, if you open the link below and click on "Show Me" and then "Toggle Transition" Button you will see a wonderfull fade in / fade out transition of 2 pictures. ...
5
by: robinsiebler | last post by:
I have a data structure that looks like this: # dates = {'2007': {'25': {'06/23/07': {'aerosmith': , # 'Metallica': }, # 'last_song': }}}...
4
by: Charles Packer | last post by:
I found a script to crossfade between two images that works okay except that in the middle of a fade when both images have equal opacity, the combined images also are tinted by the page background...
3
by: E11esar | last post by:
Hi there. This may be something I just have to live with but is there a way to stop the computer screen blinking off and then back on during a PostBack please? This is within ASP.Net and C# and...
7
by: semomaniz | last post by:
Is there a way using animation extender to blink a text? IE does not support the css style text-decoration:blink so trying to use animation extender. I am trying to create a list of to do items...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.