jQuery introducing decimals/float errors into CSS() assignments...
Sorry if this isn't the right place but this is somewhere between a question and a possible bug report.
Noticed this earlier against the latest 1.7.2 (testing in Chrome latest public release on W7-64) - not seen anything like it before so I'm wondering if something has changed recently?
I've been testing a simple loop which moves something across the screen - but I'm seeing odd behaviour (almost certainly related to float errors) when setting CSS Properties through jQuery.
Basically I do something like this repeatedly
- var val = parseInt($(myobject).css("left));
- val -= 7;
- $(myobject).css("left",val+"px");
If I test the value of the "left" property after that, I'll see results such as
- 1042
- 1035
- 1028
- 1020 <<<< !!!!
- 1013
- 1006
- ...
Digging further, what seems to be happening is that I do this
- $(myobject).css("left","1021px")
- alert($(myobject).css("left"))
and what the alert shows is "1020.99876152371253716253px"
All I can think is that jQuery is internally stripping the "1021px" and assigning a non-rounded/fixed/ceiled/floored version of the number!?