Open scottkellum opened 4 years ago
There is already the CSS Easing Functions specification which defines general interpolation functions. So, everything that can be reused between different specifications related to interpolation and generally describes different values can be transformed into each other should go there.
Having said that, I think it makes more sense to specify interpolation of units and percentages directly in the related specification, because that's where you also find the definition of what the percentages resolve against.
Sebastian
Thanks @SebastianZ,
The biggest pain point I see is not with easing functions, but with scroll-linked animations. I have also been using animations to interpolate properties across viewport and element widths (as opposed to using media queries that don’t interpolate). There is a lot of room to expand the animation spec to interpolate more than just time. I see a lot of room for new CSS around interpolation and abstracting interpolation out of animaitons seems like a great place to start.
Sorry, I'm also a little unclear about the benefit of another spec. As I an understand it we currently have:
<length>
s, or in the specification that introduces the type. This was a deliberate change so that new specs can introduce new animation types without having to update another spec, and so that implementers of new properties can easily find the accompanying animation behavior that needs to be implemented.These seem like the right places to me?
@birtles I’m excited to see this expansion in Web Animations Level 2. I was not aware of these issues and yes, they are revealing to me.
This proposal isn’t for another spec, but to abstract animations up a level into an interpolation spec to further reduce confusion as animations are being used for more and more things that aren’t time based animations. Interpolating styles across viewport and element widths is a particular feature I would like to see in CSS and this abstraction seems like a good place to start.
But again, really happy to see these changes to the keyframe spec! I remember not so eloquently trying to propose some of these changes on your initial scroll-linked animation spec.
EDIT: Turns out this was the wrong issue. Sorry!
Hi Bryce,
Which particular proposal are you referring to? The proposal to refactor specs? To define keyframe offsets using times? To define animation moment using fractions? Or something else?
I think I replied to the wrong issue. I was looking at a few things. I meant to reply to the one about changing the linear gradient syntax to allow something a bit like linear-gradient(red, ease-in-out, blue)
. Looking at this thread, this appears to be the wrong issue. I'm so sorry for that, I'll have to find the correct thread. My apologies!!
Possibly related: https://github.com/w3c/csswg-drafts/issues/581
I thought this was mentioned in this issue, but I can't find it. Another disparity / pain point is that gradients can automatically space out color stops without a position, whereas for keyframes the author needs to do it manually, often with quite ugly, annoying to maintain results.
The CSS Working Group just discussed Higher level CSS interpolation module
, and agreed to the following:
RESOLVED: This is something we want to work on, exact details TBD
The author (@brumm) of a shadow easing tool has an open source function that we could emulate a CSS version after:
const values = eaze(2, {
value: 10,
easing: easings.linear,
})
// [ [5], [10] ]
where in CSS we could have (straw man syntax):
easeValues(3, 0px to 10px, linear)
/* 0px, 5px, 10px */
it wouldn't pacify uses case like text-shadow
, box-shadow
etc because those need more than lengths, they need full values like 0 0 5px black
, and I don't think we could support use cases like that..?
box-shadow: easeValues(5,
0 2.8px 2.2px rgba(0, 0, 0, 0.02)
to
0 100px 80px rgba(0, 0, 0, 0.07),
ease-out
);`
could it? it almost starts to look like keyframes. and that also doesnt quite fulfill the use case of that shadow tool.. because it's using easing on the y
, blur
and color
values with different easings. the above pseudo code would give all 3 the same easing, creating a different visual effect that's not as good.
just sharing my thoughts!
That's interesting, as a kind of repeat()
-like interpolation for generating several values in one place.
As I understand the request here, another big part of this issue is thinking about new ways to control interpolation -- scrubbing seamlessly along the easing curve between values, based on… something.
transition
and animation
both followed a simple duration-based timeline, triggered by some event, and following through to the endanimation
can also be linked to (and controlled by) a "scroll timeline" not based on duration, but on scroll-positionCurrently, we can trigger duration-based interpolation with @media
or @container
, but we can't create new timelines based on them, the way we can with scroll-position. What would it look like to generalize out from scroll timelines, to allow even more interpolation controls?
Abstract
Numerous CSS modules have interpolation as a part of them: keyframe animations, transitions, gradients, and the new color mix functions. Consolidating interpolation into a module that makes the behavior more consistent across these, while also providing a path to new features like gradient easing, would be more logical and consistent for CSS authors.
Pain points in CSS and CSS drafts
0.5s
alongside50%
in keyframes.New possibilities for the future
Related issues