$.fx.prototype.cur() is incompatible with cssHooks
|Reported by:||anonymous||Owned by:|
To calculate the start value of a property being animated, $.fn.animate() uses $.fx.prototype.cur(). This function then tries to access the DOM property first and, should it fail, falls back to $.css(), which is cssHooks aware. Unfortunately, the value returned by $.css() is invariably parsed as a Float, which breaks values for properties such as color, transform, gradient, etc.
var r = parseFloat( jQuery.css( this.elem, this.prop ) ); return r || 0;
Currently, cssHooks workaround this problem by re-calculating the start value on the very first step of the animation, see color.js and transform.js examples. Obviously, this solution is neither clean nor efficient.
Before returning the value, cur() could simply do the following:
var r = jQuery.css( this.elem, this.prop ), parsed = parseFloat(r); return isNaN(parsed)? r : parsed;
But there's probably a good reason for it to currently return 0 when parseFloat fails. I need help finding this reason so that I can fix this bug.
Change History (9)
comment:1 Changed 6 years ago by
|Component:||unfiled → css|
|Priority:||undecided → high|
comment:6 Changed 6 years ago by
|Component:||css → effects|
|Milestone:||1.next → 1.5.1|