Serge P
Serge P

Reputation: 1863

jQuery color animate falls to "white"

There are "gaps" (switching to white color) between "red" and "orange" and between "green" and "lightblue" in both directions.

Can you please explain, why it there?

    var colors = ["red", "orange", "yellow", "green", "lightblue", "blue", "purple"];
    var pos = 0;

    switchColor();

function switchColor() {
    $("#sample").animate({color: colors[pos]}, 4000);
    pos++;
    if(colors.length == pos) {
        pos = 0;
        colors.reverse();
    }
    window.setTimeout(function() { switchColor(); }, 1500)
}

https://jsfiddle.net/dw1m021y/1/

Upvotes: 1

Views: 34

Answers (1)

Yass
Yass

Reputation: 2668

It looks like the call to animate doesn't recognise orange or lightblue because I experience no issues if I replace the values with their hexadecimal equivalents (#ffa500 for orange and #ADD8E6 for lightblue).

It might be a good idea to report the issue using the jQuery bug tracker if the workaround with the hexadecimal values isn't suitable for your needs.

Updated Fiddle

Upvotes: 1

Related Questions