@@ -167,6 +167,125 @@ Each time a new transition is generated, the current value of the (already
167167incremented) <a>current transition generation</a> is stored as the
168168transition's <dfn>transition generation</dfn> .
169169
170+ ## Defining [=before-change style=] : the ''@starting-style'' rule
171+
172+ In Level 1 of this specification, transitions can only start during a
173+ [=style change event=] for elements which have a defined [=before-change style=]
174+ established by the previous [=style change event=] . That means a transition
175+ could not be started on an element that was not being rendered for the previous
176+ [=style change event=] (see: [[css-transitions-1#starting]] ).
177+
178+ In some cases it makes sense to start transitions on newly inserted elements or
179+ elements that change from not [=being rendered=] to being rendered. To allow
180+ for that, this specification introduces ''@starting-style'' .
181+
182+ The <dfn at-rule id="at-ruledef-starting-style">@starting-style</dfn> rule is a
183+ grouping rule. The style rules inside it are used to establish styles to
184+ transition from, if the previous [=style change event=] did not establish a
185+ [=before-change style=] for the element whose styles are being computed.
186+
187+ Note: This means that ''@starting-style'' rules only apply to some elements
188+ during a computed style update, namely elements that were not rendered or part
189+ of the DOM during the previous [=style change event=] .
190+
191+ Define <dfn>starting style</dfn> for an element as the [=after-change style=]
192+ with ''@starting-style'' rules applied in addition. If an element does not have
193+ a [=before-change style=] for a given [=style change event=] , the
194+ [=starting style=] is used instead of the [=before-change style=] to compare
195+ with the [=after-change style=] to start transitions
196+ ([[css-transitions-1#starting]] ).
197+
198+ The rules inside ''@starting-style'' cascade as any other grouped style rules
199+ without introducing any new ordering to the cascade, which means rules inside
200+ ''@starting-style'' do not necessarily win over those outside.
201+
202+ Style rules in ''@starting-style'' do not apply to [=after-change style=] .
203+ Thus, the presence of matching rules in ''@starting-style'' can cause
204+ transitions to occur on elements that otherwise could not have transitions
205+ because they lack a [=before-change style=] .
206+
207+ [=Starting style=] inherits from the parent's [=after-change style=] just like
208+ [=after-change style=] does.
209+
210+ <div class=example>
211+
212+ The 'background-color' of an <code> h1</code> element can be transitioned
213+ from transparent to green when it is initially rendered:
214+
215+ <pre class=lang-css>
216+ h1 {
217+ transition: background-color 1.5s;
218+ background-color: green;
219+ }
220+ @starting-style {
221+ h1 {
222+ background-color: transparent;
223+ }
224+ }
225+ </pre>
226+
227+ Conditional rules can be used with CSS Nesting:
228+
229+ <pre class=lang-css>
230+ h1 {
231+ transition: background-color 1.5s;
232+ background-color: green;
233+ @starting-style {
234+ background-color: transparent;
235+ }
236+ }
237+ </pre>
238+ </div>
239+
240+ <div class=example>
241+ The 'opacity' of an element can be transitioned when the element changes
242+ to or from ''display: none'' :
243+
244+ <pre class=lang-css>
245+ #target {
246+ transition-property: opacity, display;
247+ transition-duration: 0.5s;
248+ display: block;
249+ opacity: 1;
250+ @starting-style {
251+ opacity: 0;
252+ }
253+ }
254+ #target.hidden {
255+ display: none;
256+ opacity: 0;
257+ }
258+ </pre>
259+
260+ The display is transitioning to allow for an opacity transition before
261+ flipping from ''display:block'' to ''display:none'' .
262+
263+ Specifying ''opacity: 0'' in the ''@starting-style'' rule means the
264+ element will transition opacity from ''0'' to ''1'' when inserted into
265+ the tree or when the <code> hidden</code> class flips 'display' from
266+ ''display/none'' to ''display/block'' as the target element does not
267+ already have a [=before-change style=] in those cases.
268+
269+ Specifying ''opacity: 0'' in the <code> #target.hidden</code> rule makes
270+ 'opacity' transition from ''1'' to ''0'' when the <code> hidden</code>
271+ class is added.
272+ </div>
273+
274+ Global, name-defining at-rules such as ''@keyframes'' , ''@font-face'' , and
275+ ''@layer'' are allowed inside ''@starting-style'' , and when present behave as
276+ if they were outside of ''@starting-style'' .
277+
278+ ### The <code> CSSStartingStyleRule</code> interface
279+
280+ The {{CSSStartingStyleRule}} interface represents a ''@starting-style'' rule.
281+
282+ <pre class='idl'>
283+ [Exposed=Window]
284+ interface CSSStartingStyleRule : CSSGroupingRule {
285+ };
286+ </pre>
287+
288+
170289# Application of transitions # {#application}
171290
172291## Animation composite order ## {#animation-composite-order}
0 commit comments