I've been working on creating an animation that switches between 2 images used as the background image of a div. Here's the code snippet I've been using:
var spacecraftInterval = setInterval(function() {
if (access == true) {
var imageUrlSpacecraft = "bk-nav-0" + currentArea;
$("#spacecraft").css(
"background-image",
"url(assets/img/" + imageUrlSpacecraft + ".png)"
);
access = false;
} else {
var imageUrlSpacecraft = "bk-nav-0" + currentArea + "-b";
$("#spacecraft").css(
"background-image",
"url(assets/img/" + imageUrlSpacecraft + ".png)"
);
access = true;
}
}, 500);
The animation works, but I've noticed that there are some moments during the transition where the background image seems to 'lag' or disappear for a few milliseconds. This issue occurs frequently. Do you think this is a browser-related problem, or is it likely an issue with my code?