ASAIK jquery animate function accepts style properties only. but i want to animate the attributes of an element. consider a SVG element rectangle
I like the Hoffmann approach, but i think is more elegant without creating a virtual dom object.
This is my coffeescript snippet
$rects.each ->
that = @
$({width: 0}).animate
width: parseInt($(@).attr('width'))
,
duration: 2000
easing: 'easeIn'
step: ->
$(that).attr 'width', Math.round(@.width)
done: ->
console.log 'Done'
which compiles into
return $rects.each(function() {
var that;
that = this;
return $({
width: 0
}).animate({
width: parseInt($(this).attr('width'))
}, {
duration: 1000,
easing: 'easeIn',
step: function() {
return $(that).attr('width', Math.round(this.width));
},
done: function() {
return console.log('Done');
}
});
});