- From: Shane Stephens <shans@google.com>
- Date: Thu, 10 Jul 2014 10:23:16 +1000
- To: "public-fx@w3.org" <public-fx@w3.org>
- Message-ID: <CAGTfzwRNaycbcoPVgeWeKSyrJ+L8bxnV=1Qhq65iepg-0uG-5Q@mail.gmail.com>
Hi list, Web Animations defines a KeyframeEffect, which allows developers to specify animations as a series of keyframes (similar to CSS Animations). Each input Keyframe contains one or more CSS property:value pairs, and an optional offset that specifies the fractional position of the keyframe, e.g. new KeyframeEffect([ {left: '100px', top: '200px', offset: 0.4}, {left: '200px', top: '100px'}]); The processing of Keyframes as currently specified is quite complicated: (1) if there are keyframes without offsets, and the keyframes with offsets are not in order, then throw an exception (2) if the keyframes are not in order then sort them (3) throw away any keyframes with offsets outside the range [0, 1] (4) if the first keyframe has no offset, give it an offset of 0. If the last keyframe has no offset, give it an offset of 1. (5) space any keyframes without offsets (either by evenly distributing them or by pacing them). Furthermore, when KeyframeEffects are used with easings that produce timing fraction values outside the range [0, 1], we need to reconstruct behavior by extrapolating the first two or last two Keyframes for offsets outside [0, 1]. We feel there are two problems with this: * it isn't easy for an author to understand when keyframe data is used, when it is silently dropped, and when an exception might occur. * we silently drop keyframes outside [0, 1] (i.e. throw away explicit data provided by the author) then reconstruct linear default behavior based on keyframes that already have another purpose (i.e. replace explicit data with an algorithm with inputs that can't be tweaked easily). Accordingly, we'd like to do better here. There are two options: (1) be extremely strict. Always throw an exception if offsets are out of order, always throw an exception if offsets are outside the range [0, 1]. This way an author immediately knows if they are providing information that isn't going to be used. (2) be extremely accepting. Distribute offsets before sorting, never throw an exception, and never throw away data outside the range [0, 1] (in fact, use a constant value outside this range if no data is available). See details below. My personal preference is to go with (1) for now as it is easy to replace it with (2) in later versions of the specification. However, I'd like to hear other opinions too - in particular, given there is a clean and efficient way of handling essentially any input, should we be doing that now rather than being strict? --- details of (2): We would process keyframes according to the following steps: (1) If the first keyframe has no offset, give it an offset of 0. If the last keyframe has no offset, give it an offset of 1. (2) space or pace any remaining keyframes without offsets (3) sort all keyframes in offset order --- Cheers, -Shane
Received on Thursday, 10 July 2014 00:23:43 UTC