473,714 Members | 2,531 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(la yerName, maxOpacity)
{
clearTimeout(fa deOutTO);
myOpacity = document.getEle mentById(layerN ame).style.opac ity;

if(myOpacity < maxOpacity)
{
myOpacity -= -0.10;
document.getEle mentById(layerN ame).style.opac ity=myOpacity;
var cmd2run="layer_ fadeIn('"+layer Name+"',"+maxOp acity+")";
var fadeSpeed=500;
fadeInTO=setTim eout(cmd2run,fa deSpeed);
}
}

function layer_fadeOut(l ayerName, maxTransparency )
{
clearTimeout(fa deInTO);
myOpacity = document.getEle mentById(layerN ame).style.opac ity;

if(myOpacity > maxTransparency )
{
myOpacity -= 0.10;
document.getEle mentById(layerN ame).style.opac ity=myOpacity;

var
cmd2run="layer_ fadeOut('"+laye rName+"',"+maxT ransparency+")" ;
var fadeSpeed=10;
fadeOutTO=setTi meout(cmd2run,f adeSpeed);
}
}

Oct 23 '05 #1
2 1585
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(la yerName,maxOpac ity)
{
clearTimeout(fa deOutTO);
myOpacity = document.getEle mentById(layerN ame).style.opac ity;

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

if(myOpacity < 1.0)
{
document.getEle mentById(layerN ame).style.opac ity=myOpacity;
}
else
{
document.getEle mentById(layerN ame).style.opac ity=0.999999;
return;
}

var cmd2run="layer_ fadeIn('"+layer Name+"',"+maxOp acity+")";
var fadeSpeed=10;
fadeInTO=setTim eout(cmd2run,fa deSpeed);

}

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
2266
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
3531
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, green, blue) { // private variable initialization this.red = red; this.green = green;
10
4688
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? Thanks
2
19319
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 should use only Double Pointers and not just ptrs.Why? 2. Usage in 2D arrays
2
2695
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. http://msdn.microsoft.com/library/default.asp?url=/workshop/author/filter/reference/filters/fade.asp I want to have the same effect in Visual C++, dosen't matter with / or without GDI+, but no .NET. I have a simple dialog with some controls and I
5
1980
by: robinsiebler | last post by:
I have a data structure that looks like this: # dates = {'2007': {'25': {'06/23/07': {'aerosmith': , # 'Metallica': }, # 'last_song': }}} I have a section where I try to loop through a set of dates and print out all of the songs for a given artist: if type == 'artist':
4
1528
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 color. Evidently the images are alpha-composited not only with each other, but by default with the background as well, creating an effect I definitely do not want. I demonstrate this at http://cpacker.org/afader in which I use a blue...
3
2437
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 an AutoPostBack operation. Thank you. M :o)
7
5557
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 and apply a blinking effect if the item required immediate attention. I used the following code to fade in and out but how do i make it last for ever (as long as user do not navigate away from the page)? <asp:Panel ID="panmsg" runat="server">...
0
8796
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8704
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9307
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9170
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9071
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4462
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4715
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3155
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2105
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.