The background image's fadeInOut transitions create a strange phenomenon where all the text appears in white

So, here's a strange issue I'm facing.

On my website, the background image changes with a smooth fadeIn/Out transition.

Video:

Website in action:

Here is the HTML markup:

<div class="fondo" onclick="descargar(2,500);descargar(1,500);"></div>
<div id="headerimgs">
    <div id="headerimg1" class="headerimg"></div>
    <div id="headerimg2" class="headerimg"></div>
</div>
<!-- Header Start -->

CSS Styles:

.headerimg { 
background-position: center top; background-repeat: no-repeat; width:100%;position:absolute;height:100%;cursor:pointer; 
 -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;

}
.headerimg img{ 
min-width:100%; width:100%; height:100%;
}

.fondo{
position:absolute;
z-index:1;
width:100%;
height:100%;
cursor:pointer;
}

Javascript Code:

/*Background Image Transition Management*/
$(document).ready(function() {
/*Control animation speed*/
var slideshowSpeed = 3000;
var transitionSpeed = 2000;
var timeoutSpeed = 500;

/*Do not touch*/
var interval;
var activeContainer = 1;    
var currentImg = 0;
var animating = false;
var navigate = function(direction) {
// If already animating, do nothing!
if(animating) {
return;
}
currentImg++;
if(currentImg == photos.length + 1) {
currentImg = 1;
}
var currentContainer = activeContainer;
if(activeContainer == 1) {
activeContainer = 2;
} else {
activeContainer = 1;
}
cargarImagen(photos[currentImg - 1], currentContainer, activeContainer);
};
var currentZindex = -1;
var cargarImagen = function(photoObject, currentContainer, activeContainer) {
animating = true;
currentZindex--;
$("#headerimg" + activeContainer).css({
"background-image" : "url(" + photoObject + ")",
"display" : "block",
"z-index" : currentZindex
});
$("#headerimg" + currentContainer).fadeOut(transitionSpeed,function() {
setTimeout(function() {
$("#headertxt").css({"display" : "block"});
animating = false;
}, timeoutSpeed);
});
};

navigate("next");

interval = setInterval(function() {
navigate("next");
}, slideshowSpeed);

});

In addition to this, there is an overlay div (class fondo) that covers the entire screen to detect when the background is clicked. The issue arises with white text during the transition effect.

Can anyone suggest what might be causing this strange behavior?

Answer №1

I'm not sure what caused the issues on your computer, as I haven't been able to replicate them myself. I have tested in IE7,8,9, the latest Chrome and Firefox on Windows 7. Could you please provide more details about your setup? Have you visited a website with 3D capabilities before testing your own site? It appears to be a problem related to the graphics card. Did you ensure that you are using the most recent browser and graphics card drivers?

As a side note, you may want to consider making your fade animation smoother: there is some stuttering in Chrome after the initial load.

An easy way to achieve this effect is by using window.setInterval with the following code:

function(){
    var container = $('#headerimgs');
    var current = container.children('div:visible:first');
    var next = (current.next().length > 1) ? current.next() : container.children('div:visible');

    current.fadeOut(300);
    next.fadeIn(300);
}

Adjust the durations to achieve the desired effect. Keep in mind that the .headerimg divs will need to be positioned absolutely for them to overlap completely.

Answer №2

Identify the starting and ending points of your fade in/out...

It's possible that there may be an asynchronous issue causing multiple fade-ins/outs to happen simultaneously or incorrectly set up. This is more of a speculation than a definitive answer, but based on experience, flickering problems with fadeIn/fadeOut often stem from this issue (about 90% of the time).

Be sure to also review any CSS properties/events related to mouseover/mouseenter.

I apologize for not being able to troubleshoot it myself since I can't replicate the error either.

On a side note: Chrome sometimes doesn't display these asynchronous errors quickly enough, making them practically invisible to the naked eye. The same goes for extremely fast computers where the error might occur within a single frame (or go unnoticed altogether).

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Properly storing information in the mongoDB

Having trouble saving data in my Angular application correctly. Here is a snippet of my API code: .post('/type/add', function(req, res){ var type = new NewType({ type: req.body.type, subtype: req.body.subtype, }); type.save ...

Steps to show an input button and exit the current window

I am looking for guidance on how to enable or display an input on a webpage if an ajax call is successful. I want this input, when clicked, to be able to close the current window using JavaScript. What would be the most efficient way to accomplish this? B ...

Is there a way for me to adjust the font size across the entire page?

Most CSS classes come with a fixed font-size value already set. For instance: font-size: 16px font-size: 14px etc. Is there a way to increase the font size of the entire page by 110%? For example, font-size: 16px -> 17.6 font-size: 14px -> 15.4 ...

Plupload - Resize image upon upload with minimum height and width requirements, rather than maximum requirements

I am currently using a Plupload uploader that creates both a thumbnail and a large size image for each upload. The issue I am facing is with resizing the thumbnail to fit into a 150x150px box. I have tried using some javascript to scale down the image, but ...

What is the most efficient way to load data just once when a user reaches the bottom of the page?

I am encountering an issue with a webpage that dynamically loads HTML from a PHP script which scraps image links from another site when the user scrolls to the bottom of the page. The problem is that the scraping script takes some time to complete, causing ...

The Javascript document refuses to load

I am currently working on a website with the main file named index.html: <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>Title</title> </head> ...

What is the best way to align a div with a td within a table?

I have a table and I inserted a div inside it, but now the alignment with the td is off. I applied display: inline-block to both the td and div elements, but the td only shifted slightly. How can I correct this? Here's my HTML code for the table : ...

Obtain individual information from XML

After fetching data from the server using ajax, I am looking to retrieve only a specific part of the data which is the name. How can I modify my code to achieve this? const url = 'https://jsonplaceholder.typicode.com/users' const xhr = new XMLH ...

Having trouble fetching JSON on the server (NodeJs) as I keep receiving the error "Unexpected Token U in position 0"

I have gone through several posts on dealing with sending and retrieving JSON using NodeJs and Express, but I am still struggling to make it work. Someone mentioned that the issue might be due to invalid JSON. var arr = { City: 'someplace', Coun ...

Is it necessary to encode special characters in a JSON object?

I am currently working on a code where I am taking a class and converting it to JSON format. Throughout my testing, all the content is surrounded by double quotes, for example: { "a" : "hello world ! '' this is john's desk" } I am wonderi ...

Tips for maintaining the fixed positioning of the left and right flex elements (sidebars) as the middle element scrolls, with the scroll bar located on the right side

I am currently designing a webpage with three main elements: a left sidebar, a right sidebar, and a central feed that is 600px wide and scrolls. The scroll bar must be positioned on the right side of the screen, allowing users to scroll by simply using the ...

Discover the ins and outs of integrating YAML front matter into your destination directory path

I am looking to customize the path of my blog posts to include a fancy date format like /blog/2013/09/17 so that the links from my previous octopress blog remain intact. Within the YAML front matter on each markdown page, I have included the date informat ...

Experiencing issues when attempting to access the open weather API through Ajax?

I have been working on calling the open weather API endpoint in order to retrieve weather data. I am implementing an AJAX call to achieve this, but unfortunately I am facing difficulties in retrieving the data and encountering errors. The script executi ...

A clever method for implementing lazy-loading using mobx

Can you provide guidance on the most effective way to lazy load properties with MobX? I've been grappling with this issue for a few days now, and I've struggled to find suitable examples ever since strict mode was introduced. While I appreciate ...

Using Two JavaScript Functions with Identical Names in One HTML File

I am currently facing an issue with a function where the data is retrieved from the getValue() function. The following code snippet is a fragment. grid.js function gridLoadComplete(){ var data = getValue(); } Take into account the following H ...

What is the best method for combining several variables into a single one using a parameter?

On the webpage, there is a table containing 11 checkboxes. I am looking to create a keyword that allows testers to input just 1, 2, or 3 to select a specific checkbox without needing multiple lines of element variables. Here are the elements: xpath=(//in ...

Tips for utilizing the material ui auto-complete search feature

I am in search of an alternative to material-ui-search-bar because it is no longer being maintained. I have been suggested to try using Material UI's auto complete instead. However, from the examples I've seen, it seems like only text field struc ...

Angular Pagination: Present a collection of pages formatted to the size of A4 paper

Currently, I am working on implementing pagination using NgbdPaginationBasic in my app.module.ts file. import { NgbdPaginationBasic } from './pagination-basic'; My goal is to create a series of A4 size pages with a visible Header and Footer onl ...

Utilizing nested flex containers with overflow-x property

I'm looking to set up a layout with 2 columns side by side. The first column should have a fixed width of 200px, while the second column should take up the remaining space on the screen. Additionally, I want the content in the second column to auto-sc ...

Error in jQuery and Canvas Image Crop: The index or size is invalid, exceeding the permissible limit

Recently, I downloaded and installed the Canvas Image Crop plugin from CodeCanyon but encountered a problem specifically on firefox. An error message kept popping up whenever I tried to upload certain images: "Index or size is negative or greater than the ...