1- # Explainer: calc-size() function for transitions and animations to/from intrinsic sizes
1+ # Explainer: interpolate-size property and calc-size() function for transitions and animations to/from intrinsic sizes
22
33## Authors:
44
@@ -15,22 +15,30 @@ It is important for animation of elements
1515(such as the contents of disclosure widgets)
1616opening/closing between a content-based height (or width)
1717and a small (often zero) height (or width).
18- This ` calc-size() ` proposal fits the desire to do such animations
18+ This proposal fits the desire to do such animations
1919into the way that CSS transitions and animations work.
2020More generally,
2121this allows animating
2222between a fixed length and
2323almost any type of height (or width, or min/max-height/width)
2424that can currently be specified in CSS.
2525
26- The CSS ` calc-size() ` function is a CSS function similar to calc(),
26+ The CSS ` calc-size() ` function is a CSS function similar to ` calc() ` ,
2727but that also supports operations on exactly one of the values
2828auto, min-content, max-content, fit-content, stretch, or contain,
2929which are the intrinsic sizing keywords.
30- This allows transitions and animations to and from these values
31- (or mathematical functions of these values),
32- as long as the ` calc-size() ` function is used
33- on at least one of the endpoints of the transition or animation to opt in.
30+ This allows transitions and animations to and from these keyword values
31+ (or mathematical functions of these values)
32+ by providing a syntax for representing fractions of these values.
33+
34+ The CSS ` interpolate-size ` property allows authors to opt pages in
35+ to having CSS transitions and animations work with these keywords.
36+ Since this opt-in is needed for compatibility with web content
37+ that assumes that these animations do * not* work,
38+ the recommended way to use the opt-in is to specify it once on the root element
39+ to opt in the entire page:
40+ ` :root { interpolate-size: allow-keywords } ` .
41+ This will make animations and transitions to and from these keywords work.
3442
3543## Goals
3644
@@ -89,8 +97,8 @@ It is designed to fit in to the existing CSS mechanisms for transitions and anim
8997
9098## ` calc-size(<basis>, <calculation>) `
9199
92- The basic form of the proposal is a ` calc-size() ` function that takes two arguments.
93- (There is also a one-argument form for convenience; see below.)
100+ The underlying mechanism that is added to support these animations is
101+ a ` calc-size() ` function that takes two arguments.
94102The first argument is the * basis* and the second argument is the * calculation* .
95103It is similar to the existing ` calc() ` function but is accepted only
96104for [ a small set of CSS properties] ( https://github.com/w3c/csswg-drafts/issues/626#issuecomment-2025918637 )
@@ -142,6 +150,20 @@ details[open]::details-content {
142150
143151This is specified [ in css-values-5] ( https://drafts.csswg.org/css-values-5/#calc-size ) .
144152
153+ ## ` interpolate-size `
154+
155+ The CSS ` interpolate-size ` property is an inherited property that takes two values:
156+ ` numeric-only ` (the initial value) and ` allow-keywords ` .
157+ It exists because there is enough web content that depends on
158+ intrinsic sizing keywords * not* animating
159+ that we need a way for pages to opt in to allowing these animations.
160+
161+ Since it is an opt-in for compatibility,
162+ it is designed to make it easy to opt in the entire page.
163+ Therefore, it is an inherited property so that it can just be specified once on the root.
164+ It is also not part of any shorthands because being part of a shorthand
165+ would cause use of the shorthand to reset the opt-in.
166+
145167## Detailed design discussion
146168
147169Much of the design discussion happened in w3c/csswg-drafts #626
@@ -150,7 +172,8 @@ starting with
150172There has also been further discussion in
151173[ w3c/csswg-drafts #10220 ] ( https://github.com/w3c/csswg-drafts/issues/10220 ) ,
152174[ w3c/csswg-drafts #10259 ] ( https://github.com/w3c/csswg-drafts/issues/10259 ) , and
153- [ w3c/csswg-drafts #10294 ] ( https://github.com/w3c/csswg-drafts/issues/10294 ) .
175+ [ w3c/csswg-drafts #10294 ] ( https://github.com/w3c/csswg-drafts/issues/10294 )
176+ (for ` interpolate-size ` ).
154177
155178## Considered alternatives
156179
0 commit comments