$.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 rwaldron
- Component changed from unfiled to css
- Keywords needsreview added
- Priority changed from undecided to high
comment:6 Changed 6 years ago by dmethvin
- Component changed from css to effects
- Keywords needsreview removed
- Milestone changed from 1.next to 1.5.1
comment:8 Changed 6 years ago by louisremi
- Resolution set to fixed
- Status changed from open to closed