score:1

Accepted answer

It's because during the loop action isn't being reinitialized with an empty object.

Fiddle http://jsfiddle.net/oliverseal/qc75H/1/

It should be:

colors = ['#e03d56', '#fecd6e', '#8fe1bf', '#9ab3f1']

i = 0
txtc = $('.text-cycle').css('color', '#e03d56')
bgc  = $('.bg-cycle').css('background-color', '#e03d56')

changeColor = (ob) ->
  i++; i = i % 4

  $.each ob, ->
    action = {}
    action[this.toChange] = colors[i]
    this.el.animate action,
        duration: 8000, complete: () -> changeColor ob

#heights '.max-image-place, .max-image'
changeColor [
    {el: txtc, toChange: 'color'}
    {el: bgc, toChange: 'backgroundColor'}
]

Related Query

More Query from same tag