Skip to content

Commit 6ad5280

Browse files
committed
Clarify inherited animation properties and update guidance on shorthand usage in styling documentation
1 parent b22c2eb commit 6ad5280

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/content/docs/basics/styling.mdx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,10 @@ Of course, you can add animations to those elements. This has the benefit that y
206206

207207
### Inherited Animation Properties
208208

209-
The values for `animation-duration`, `animation-delay`, and `animation-fill-mode` are inherited from parent in the pseudo-element tree.
209+
The API explicitly sets the values for [duration and fill-mode](/basics/styling/#group--morph-animation) to `0.25s` and `both` at the group level. All other properties keep their defaults, if you do not explicitly override them: `animation-timing-function: ease`, `animation-iteration-count: 1`, `animation-direction: normal`, and `animation-play-state: running`.
210210

211-
The [API sets the defaults](/basics/styling/#group--morph-animation) to `0.25s`, `0s`, and `both`.
211+
All pseudo-elements (but groups) inherit the `animation-*` values from their parent in the pseudo-element tree.
212212

213-
Recently, all other animation properties but `animation-name` where added to the list.
214213

215214
```css
216215
::view-transition-image-pair(*),
@@ -225,9 +224,9 @@ Recently, all other animation properties but `animation-name` where added to the
225224
animation-play-state: inherit;
226225
}
227226
```
228-
If the browser only supports the short list, the `animation-timing-function`, `animation-iteration-count`, `animation-direction`, and `animation-play-state` properties keep their default values: `ease`, `1`, `normal`, and `running` respectively.
229227

230-
Due to these default inherits you might want to prefer setting the individual `animation-...` properties instead of using the `animation` shortcut, which would reset `animation-duration`, `animation-delay` and `animation-fill-mode` to `0s`, `0s`, and `none` if not explicitly stated otherwise.
228+
Using `inherit` is a good idea as it allows for control over several animations at once.
229+
231230

232231
For example you can set the duration of all unchanged morph and cross-fade animations with a single rule:
233232

@@ -237,7 +236,10 @@ For example you can set the duration of all unchanged morph and cross-fade anima
237236
}
238237
```
239238

240-
Using `inherit` in your own definitions is a good idea as it allows for control over several animations at once.
239+
Due to these default inherits, you might want to prefer setting the individual `animation-...` properties instead of using the `animation` shorthand. All properties that you do not set explicitly in the shorthand will be reset to their defaults. This will not only override the `inherit` values from the user-agent stylesheet, breaking the original idea of controlling several animations with a single rule. The shorthand would also reset `animation-duration` and `animation-fill-mode` to `0s`, and `none`, which might lead to some hard to detect bugs.
240+
241+
Historical note: In the early days of the API, browsers only inherited duration, delay and fill mode. But today chances are very rare to encounter a browser that does not inherit all animation properties. If you want to be sure, test the browser in question with the [test page](/basics/test-page/).
242+
241243

242244
### Non-Animation Properties
243245

0 commit comments

Comments
 (0)