I needed to create a function that changes and animates the background image, to give it a cool fade-in effect when triggered. However I have run into a weird issue. So as for my function below, it works, in the sense that it changes the background image when run. But it does not animate. It just instantly changes the background image. I have tried messing with the "transition" property, using background, background-image, and others, but to no avail. Can someone help me understand why the animation part is failing to trigger?
function postBackgroundImage(url){
var bg = dom.el("topLayer");
bg.src = url;
bg.style.backgroundImage = "url("+bg.src+")";
bg.style.transition = "all 2s linear 1s";
}