Re: Animating mixed units

On 3/31/11 6:01 AM, Jérémie Patonnier wrote:
> 1. I tried to animate from 0 pixel to 100% and it fails. If I try to animate from 0% (explicitly) to 100%, all browsers work fine. So the question is : What is the f*** difference between 0px and 0% ?

How it's stored internally by the UA, basically.

> This is amazingly confusing for author.

Agreed.

> I really think that in that case, the way Mozilla handle this is the best way for authors.

For what it's worth, the way this works in Mozilla is that animating 
from Npx to M% sets the style at time t to -moz-calc((1-t)*Npx + t*M%). 
  So once browsers generally support CSS calc() I would think they will 
also support interpolating between absolute lengths and percentages.  If 
you _don't_ have the infrastructure for calc(), this is a bit of a pain 
and there is no decent way to hack it in (with the exception you point 
out for 0% vs 0px, which could be special-cased).  In particular, 
getting things right in the case when the width against which the 
percentage is resolved were also time-varying while interpolating 
between a nonzero absolute length and a nonzero percentage basically 
requires the same machinery that calc() requires.

-Boris

Received on Thursday, 31 March 2011 13:10:17 UTC