New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[web-animations-2] Custom effects #6861
Comments
That all makes sense to me. Thanks for picking this up. |
Is there a related CSS value interpolation API? |
I hadn't considered that, but it's something that's worth exploring alongside this proposal. Would you have something to propose? |
I'm not super experienced in interpolation and/or making proposals for the csswg, I wouldn't mind though, however, I'm mostlikely going to need some help. cc @mattgperry |
Hey @graouts This came out of a discussion between @okikio and myself about the limitations custom effects leaves us with. I'm super excited about custom effects but I think there's a remaining black hole when talking about interpolating complex values like My first thought was having const mixColors = new Interpolation("#f00", "rgba(255,255,255,0.5)")
document.timeline.animate(p => {
arbitraryElement.innerHTML = mixColors(circIn(p))
}) Ideally the interpolator would support unclamped progress values so we could support overshoot easing. Supported interpolators that would be helpful:
All of these (and more) are already leveraged within browsers, I think direct access would pair very well with |
In addition to what @mattgperry posted something like this would also be awesome, CSS.mix("50٪ by ease", "red", "blue") // purple (in rgb format)
CSS.mix("50٪ by ease", "currentColor", "blue", document.querySelector(".red-text")) // purple (in rgb format)
// Easing is linear by default
// Percentages function like they would on normal CSS
CSS.mix(0.5, "100%", "200", document.querySelector(".red-text"), "width") // 150px The API would very similar to the currently discussed CSS counter part |
I would like to revive work on custom effects, an idea currently unofficially drafted in Web Animations Level 2. I have filed a patch for WebKit to support the
CustomEffect
interface as well as a newdocument.timeline.animate()
method. The motivation is to bridge the gap between the poorly-named and rudimentaryrequestAnimationFrame()
and Web Animations allowing authors to harness the full power of the Web Animations model such that scripted animations may be paused, resumed, seeked, etc.Some example usage:
This code is equivalent to the more idiomatic:
The idea here is that
document.timeline.animate()
should be toCustomEffect
whatelement.animate()
is toKeyframeEffect
.The section on custom effects in the current level 2 spec starts with this issue:
I personally think that a dedicated
CustomEffect
interface is a simple and purposeful way to specify an animation where its application is performed by script. I expect that it is simpler to specify how this specific class of effects would work rather than trying to add anonupdate
callback that would apply to keyframe effects as well.You'll also notice the lack of a
target
forCustomEffect
. I believe that it should not be necessary to specify a target for a custom effect since it may not target a single node, or even a node at all, but rather a JS object controlling the rendering of a scene using<canvas>
APIs.That being said, I am very open to all feedback to work towards exposing callback-based animations in Web Animations. All work conducted in WebKit is behind an off-by-default experimental feature flag and we have no intention to expose this to the Web until we have consensus on the way forward.
Cc @birtles @flackr @stephenmcgruer @kevers-google @majido @smfr @grorg @hober @ogerchikov @BorisChiou @hiikezoe
The text was updated successfully, but these errors were encountered: