W3C home > Mailing lists > Public > public-fx@w3.org > July to September 2014

[web-animations] NaN vs null to represent unresolved / invalid times

From: Brian Birtles <bbirtles@mozilla.com>
Date: Wed, 09 Jul 2014 09:58:27 +0900
Message-ID: <53BC93B3.5080602@mozilla.com>
To: "public-fx@w3.org" <public-fx@w3.org>
Hi,

Currently Web Animations uses null to represent time values that are 
somehow invalid or unresolved.

For example, if an animation is not attached to a player, its local time 
will be null to indicate that it's not playing and nor does it have any 
intention of doing so.

Likewise, an animation timeline that is not yet ready to play can return 
null for its current time to distinguish between a timeline that has 
just begun and one that is somehow inactive.

However, this can be problematic if application code has, e.g.

   var timeRemaining =
      animation.computedTiming.activeDuration -
      animation.computedTiming.localTime;

since localTime, if null, will be treated as 0 giving the wrong result 
(particularly when startTime != 0).

I'm thinking, therefore, that we should use NaN across the board to 
represent unresolved/invalid times.

So
      readonly double? localTime
becomes
      readonly unrestricted double localTime

It probably makes sense to update the timing model description to refer 
to generic "unresolved" values (SMIL does this, by coincidence) and 
convert them to NaN at the interface.

Any thoughts?

Brian
Received on Wednesday, 9 July 2014 00:58:42 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:49:50 UTC