开发者

Add an animation to a simple carousel

开发者 https://www.devze.com 2023-03-06 03:14 出处:网络
I have a very simple banner change script: document.getElementById(\"car_head\").innerHTML = carousel开发者_运维知识库[carousel_num][0];

I have a very simple banner change script:

document.getElementById("car_head").innerHTML = carousel开发者_运维知识库[carousel_num][0];
document.getElementById("car_text").innerHTML = carousel[carousel_num][1];
document.getElementById("car_pic").src = carousel[carousel_num][2];

This changes the content of my header on a timer.

How can I add a simple animation to it? Would adding a fade in/out animation be different than adding a slide in/out animation?

Thanks,


You would need to loop through it with some form of an animation loop that gradually changes the value you want (alpha, x/y, whatever). For example:

var change = function() {
    x -= 10;
    y -= 2;
    styleThese();
    if (x > 10 && y > 0) {
        setTimeout(change, 20);
    }
}

change();

Obviously this code doesn't really work. Just work off of that basic idea.

0

精彩评论

暂无评论...
验证码 换一张
取 消