Skip to content
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

Apply transitions to media/container queries [css-contain][css-transitions] #6581

Closed
scottkellum opened this issue Sep 7, 2021 · 4 comments

Comments

@scottkellum
Copy link

Add the ability of transitioning between @media and @contain states. This would enable fine-tune control over how things change as viewport and container sizes change with easing.

This would enable at least two things that is not possible in CSS:

  • Interpolation of multiple properties across screen/container sizes.
  • Interpolation of text on an easing curve, as opposed to linear with viewport/container unit interpolation.

Some examples to show the need for this feature. These demos are acting as if text in page modules can be interpolated based on container width units in the first column, and transitioned + eased queried properties in the second column.

Possible with container unit interpolationPossible with state transitions and easing
A demo showing The Atlantic’s home page with various entry modules scaled as if with linear interpolation. This results in text not having a good size range and the typography  is a little flat. A demo showing The Atlantic’s home page with various entry modules scaled as if with easing. The result is more rich and dynamic typography.
A Nike product demo showing product names linearly interpolated resulting on the text being too big at smaller sizes. A Nike product demo with an interpolation curve showing smaller product names that ramp up to large sizes more gradually.
@mirisuzanne
Copy link
Contributor

I like this idea, and have a few notes from previous conversation with Scott. I think most relevant:

  • The most common use-case is that each property has a start-value and end-value aligned to particular container sizes, and an easing curve to interpolate. It’s rare (but not impossible) for a single property to have additional/intermediate “stops” defined. In that way, it can be thought of more like a transition than a keyframe animation.
  • However, it is useful to define multiple related properties in the same place, even if they have different start/end points. A keyframe animation with multiple stops makes that possible in Typetura.

I could imagine an approach similar to @scroll-timeline, or a way to use media/container breakpoint values directly in the keyframes rule (or some variant of it), though I haven't started digging into the details of either approach. Unlike scroll-timeline, I don't think it works for the "source" element to be hard-coded (unless it is the viewport). For a container-relative approach, authors should be able to describe the animation/timeline once, and have it respond to individual container contexts.

@mirisuzanne
Copy link
Contributor

@scottkellum Is this a duplicate of #6245 ?

@scottkellum
Copy link
Author

@mirisuzanne its a little more specific as to the interpolation being from transitions instead of animations after a chat with @una . But yes, very similar.

@mirisuzanne
Copy link
Contributor

Closing as a duplicate of #6245

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants