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

8311895: CSS Transitions #870

Closed
wants to merge 63 commits into from
Closed
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
7195ae9
Implementation of CSS transitions
mstr2 Aug 15, 2022
662345f
allow transition with zero duration
mstr2 Aug 16, 2022
7b577f9
Running transition timers are stopped when their target property is c…
mstr2 Aug 16, 2022
32e427b
Transitions are stopped when the Node is removed from the scene
mstr2 Aug 16, 2022
cf1976f
Added TransitionEvent
mstr2 Aug 21, 2022
3ce272e
typo
mstr2 Aug 21, 2022
8d09466
Added CSS documentation
mstr2 Aug 24, 2022
0046c6c
Fixed default values for transition properties
mstr2 Aug 24, 2022
13d0fd9
Factor out StyleableTimer
mstr2 Aug 24, 2022
2cfe17d
Added documentation for TransitionDefinition
mstr2 Aug 24, 2022
e0b1ad4
Events are fired when duration is zero
mstr2 Aug 25, 2022
7ceb41d
Refactored duration parsing
mstr2 Aug 25, 2022
abc8475
Ensure that property names are case-sensitive
mstr2 Aug 26, 2022
083fb00
Fix case sensitivity of 'all' identifier
mstr2 Aug 26, 2022
d983308
Refactored TransitionTimer
mstr2 Aug 27, 2022
e34a549
Removed public Node API
mstr2 Jul 11, 2023
2556c7c
Revert changes
mstr2 Jul 11, 2023
559c9b5
Make step interpolators public API
mstr2 Jul 12, 2023
1ddeef4
Added FX compat interpolators
mstr2 Jul 12, 2023
175ce1e
Fix interpolator cache
mstr2 Jul 13, 2023
5b52a80
Remove AbstractPropertyTimer
mstr2 Jul 13, 2023
ce29bfe
Refactor TransitionTimer.tryStop
mstr2 Jul 13, 2023
b68554f
Add tests
mstr2 Jul 14, 2023
3a308bf
Added fast reversing of interrupted transitions
mstr2 Jul 15, 2023
59d5e1e
Remove unused code
mstr2 Jul 15, 2023
2527b83
Refactoring
mstr2 Jul 15, 2023
99078b5
Added documentation
mstr2 Jul 15, 2023
8ff3674
Refactoring
mstr2 Jul 16, 2023
80561f6
Start transitions only for showing nodes
mstr2 Jul 17, 2023
5e179cb
Intern parsed property names
mstr2 Jul 17, 2023
1fc2c03
Refactoring
mstr2 Jul 25, 2023
2607a1e
Redundant transitions are discarded
mstr2 Jul 26, 2023
d68cfe7
Added manual test application
mstr2 Jul 26, 2023
e1e0db6
Removed trailing whitespace
mstr2 Jul 26, 2023
9cdeb49
Removed test
mstr2 Jul 26, 2023
8e46c89
Make TransitionEvent final
mstr2 Jul 31, 2023
94fa9d2
Review changes
mstr2 Jul 31, 2023
66ee849
Make interpolator fields final
mstr2 Jul 31, 2023
deb65ea
Review changes
mstr2 Jul 31, 2023
da61e64
Review changes
mstr2 Aug 1, 2023
0b77908
Added documentation
mstr2 Aug 9, 2023
035fe5c
Merge branch 'master' into feature/css-transitions
mstr2 Oct 28, 2023
482b1ec
Test whether two Interpolatable instances are compatible
mstr2 Oct 31, 2023
0fc3861
Add TransitionMediator
mstr2 Mar 18, 2024
df39f3f
Merge branch 'master' into feature/css-transitions
mstr2 Mar 18, 2024
b76568c
Merge branch 'master' into feature/css-transitions
mstr2 Mar 18, 2024
22aa4d6
Changes per review
mstr2 Mar 18, 2024
1595a19
Discard redundant transitions in StyleableProperty impls
mstr2 Mar 31, 2024
7edb374
Merge branch 'master' into feature/css-transitions
mstr2 Mar 31, 2024
f7ab6db
Change javadoc comment
mstr2 Mar 31, 2024
f996f8f
Fix javadoc error
mstr2 Mar 31, 2024
137a00c
update 'since' tags
mstr2 Mar 31, 2024
6614abb
Merge branch 'master' into feature/css-transitions
mstr2 May 2, 2024
eb60862
fixed documentation
mstr2 May 24, 2024
1a7b720
use existing property in test
mstr2 May 24, 2024
8c6b9a4
extract magic string to named constant
mstr2 May 24, 2024
a43dee3
Merge branch 'refs/heads/master' into feature/css-transitions
mstr2 May 24, 2024
d3184e6
address review comments
mstr2 May 25, 2024
4cb6c87
added documentation
mstr2 May 25, 2024
f64ad70
documentation change
mstr2 May 26, 2024
8a938dc
document css parser limitation
mstr2 May 28, 2024
10c06a9
Merge branch 'refs/heads/master' into feature/css-transitions
mstr2 May 31, 2024
29f43ed
link to easing function images in scene
mstr2 Jun 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ <h2>Contents</h2>
<li><a href="#intronaming">Naming Conventions</a></li>
<li><a href="#intropublicapi">CSS Public API</a></li>
<li><a href="#introinheritance">Inheritance</a></li>
<li><a href="#introtransitions">Transitions</a>
<li><a href="#introatrules">&#64; Rules</a></li>
<li><a href="#introexamples">Examples</a></li>
<li><a href="#introparserwarnings">Understanding Parser Warnings</a></li>
Expand All @@ -277,6 +278,7 @@ <h2>Contents</h2>
<li><a href="#typefont">&lt;font&gt;</a></li>
<li><a href="#typepaint">&lt;paint&gt;</a></li>
<li><a href="#typecolor">&lt;color&gt;</a></li>
<li><a href="#typeeasingfunction">&lt;easing-function&gt;</a></li>
<li><a href="#typetextbounds">&lt;text-bounds&gt;</a></li>
</ul>
</li>
Expand Down Expand Up @@ -680,6 +682,80 @@ <h3><a id="introinheritance">Inheritance</a></h3>
inherited provided there is not an author or an inline-style that applies specifically to that node.
In this case, the inherited font is created from the user-set font and any parts of the applicable
author or in-line style.

<h3><a id="introtransitions">Transitions</a></h3>
<p>JavaFX supports <em>implicit transitions</em> for properties that are styled by CSS. When a property value is
changed, it smoothly transitions to the new value over a period of time. Implicit transitions are supported
for all primitive types, as well as for types that implement <code>javafx.animation.Interpolatable</code>.</p>
<p>Transitions can be defined for any node in the JavaFX scene graph with the following properties:</p>
<table class="csspropertytable">
<caption>Transition Properties</caption>
<thead>
<tr>
<th class="propertyname" scope="col">CSS Property</th>
<th class="value" scope="col">Values</th>
<th scope="col">Default</th>
<th scope="col">Comments</th>
</tr>
</thead>
<tbody>
<tr>
<th class="propertyname" scope="row">transition&#8209;property</th>
<td class="value">[ none | all | &lt;custom&#8209;ident&gt;# ]</td>
<td class="default">all</td>
<td>The name of the CSS property to which the transition is applied.</td>
</tr>
<tr>
<th class="propertyname" scope="row">transition&#8209;duration</th>
<td class="value"><a href="#typeduration" class="typelink">&lt;duration&gt;#</a></td>
<td class="default">0s</td>
<td>The duration of the transition, not including an optional delay before the transition starts.</td>
</tr>
<tr>
<th class="propertyname" scope="row">transition&#8209;timing&#8209;function</th>
<td class="value"><a href="#typeeasingfunction" class="typelink">&lt;easing&#8209;function&gt;#</a></td>
<td class="default">ease</td>
<td>The easing function that is used to calculate the intermediate values.</td>
</tr>
<tr>
<th class="propertyname" scope="row">transition&#8209;delay</th>
<td class="value"><a href="#typeduration" class="typelink">&lt;duration&gt;#</a></td>
<td class="default">0s</td>
<td>The delay after which the transition starts. If a negative delay is specified, the transition starts
as if it had already been running for the specified time.</td>
</tr>
<tr>
<th class="propertyname" scope="row">transition</th>
<td class="value">
&lt;single-transition&gt;#
<br/><br/>
<strong>where</strong> &lt;single&#8209;transition&gt; = [ none | all | &lt;custom&#8209;ident&gt; ] ||
<a href="#typeduration" class="typelink">&lt;duration&gt;</a> ||
<a href="#typeeasingfunction" class="typelink">&lt;easing&#8209;function&gt;</a> ||
<a href="#typeduration" class="typelink">&lt;duration&gt;</a>
</td>
<td class="default"></td>
<td>Short-hand notation for the individual properties. Note that while the order of the values generally
doesn't matter, the first duration is always assigned to the <strong>transition-duration</strong>
property, while the second duration is always assigned to the <strong>transition-delay</strong>
property.</td>
</tr>
</tbody>
</table>
<h4>Example</h4>
<p>A button that smoothly changes its opacity on mouse-hover can be defined in a stylesheet like this:</p>
<p class="example">
.button {</br>
&nbsp;&nbsp;&nbsp; -fx-opacity: 0.8;</br>
&nbsp;&nbsp;&nbsp; transition-property: -fx-opacity;</br>
&nbsp;&nbsp;&nbsp; transition-duration: 0.5s;</br>
}</br>
</br>
.button:hover {</br>
&nbsp;&nbsp;&nbsp; -fx-opacity: 1;</br>
}
</p>

<h3><a id="introatrules">&#64; Rules</a></h3>
<p>
Beginning with JavaFX 8u20, the CSS
Expand Down Expand Up @@ -1579,6 +1655,128 @@ <h4>Color Functions <span class="grammar" style="font-size: smaller;">&lt;color-
href="#typecolor"
class="typelink">&lt;color&gt;</a>
) ]+ </span></p>

<h3><a id="typeeasingfunction">&lt;easing-function&gt;</a></h3>
<p class="grammar">linear | &lt;cubic-bezier-easing-function&gt; | &lt;step-easing-function&gt; | &lt;fx-easing-function&gt;</p>
<p><strong>Linear</strong> <span class="grammar" style="font-size: smaller;">linear</span><br/>
The linear easing function is a simple linear mapping from the input progress value to the output progress value.</p>
<figure style="display: inline-block">
<img src="easing-linear.svg" width="200" alt="Linear easing function">
</figure>
<p><strong>Cubic Bézier Easing Functions</strong> <span class="grammar" style="font-size: smaller;">&lt;cubic-bezier-easing-function&gt;</span></br></p>
<p class="grammar">ease | ease-in | ease-out | ease-in-out | cubic-bezier(<a href="#typenumber" class="typelink">&lt;number&nbsp;[0,1]&gt;</a>, <a href="#typenumber" class="typelink">&lt;number&gt;</a>, <a href="#typenumber" class="typelink">&lt;number&nbsp;[0,1]&gt;</a>, <a href="#typenumber" class="typelink">&lt;number&gt;</a>)</p>
<p>The values have the following meaning:</p>
<table style="margin-left: 40px;">
<tr>
<td style="width: 120px; vertical-align: top"><span class="grammar">ease</span></td>
<td>equivalent to <span class="grammar">cubic-bezier(0.25, 0.1, 0.25, 1)</span></td>
</tr>
<tr>
<td style="width: 120px; vertical-align: top"><span class="grammar">ease-in</span></td>
<td>equivalent to <span class="grammar">cubic-bezier(0.42, 0, 1, 1)</span></td>
</tr>
<tr>
<td style="width: 120px; vertical-align: top"><span class="grammar">ease-out</span></td>
<td>equivalent to <span class="grammar">cubic-bezier(0, 0, 0.58, 1)</span></td>
</tr>
<tr>
<td style="width: 120px; vertical-align: top"><span class="grammar">ease-in-out</span></td>
<td>equivalent to <span class="grammar">cubic-bezier(0.42, 0, 0.58, 1)</span></td>
</tr>
<tr>
<td style="width: 120px; vertical-align: top"><span class="grammar">cubic-bezier</span></td>
<td>defines the control points P1 and P2 using four real numbers: (x<sub>P1</sub>, y<sub>P1</sub>, x<sub>P2</sub>, y<sub>P2</sub>)</td>
</tr>
</table>
<p>A cubic Bézier function is defined by four control points, where P0 is fixed at (0,0) and P3 is fixed at (1,1).
P1 and P2 are restricted to the interval [0,1] on the input progress axis:</p>
<figure style="display: inline-block">
<img src="easing-cubicbezier.svg" width="200" alt="Cubic Bèzier easing function">
</figure>
<p><strong>Step Easing Functions</strong> <span class="grammar" style="font-size: smaller;">&lt;step-easing-function&gt;</span></p>
<p class="grammar">step-start | step-end | steps(<a href="#typenumber" class="typelink">&lt;integer&gt;</a>[,&lt;step-position&gt;]?)</p>
<p class="grammar">where &lt;step-position&gt; = jump-start | jump-end | jump-none | jump-both | start | end</p>
<p>The values have the following meaning:</p>
<table style="margin-left: 40px;">
<tr>
<td style="width: 120px; vertical-align: top"><span class="grammar">step-start</span></td>
<td>equivalent to <span class="grammar">steps(1, start)</span></td>
</tr>
<tr>
<td style="width: 120px; vertical-align: top"><span class="grammar">step-end</span></td>
<td>equivalent to <span class="grammar">steps(1, end)</span></td>
</tr>
<tr>
<td style="width: 120px; vertical-align: top"><span class="grammar">steps</span></td>
<td>defines a step function with <a href="#typenumber" class="typelink">&lt;integer&gt;</a> intervals
and an optional <span class="grammar">&lt;step-position&gt;</span>;<br/>if omitted,
<span class="grammar">end</span> is implied</span>
</td>
</tr>
<tr><td><br/></td></tr>
<tr>
<td style="width: 120px; vertical-align: top"><span class="grammar">jump-start</span></td>
<td>the interval starts with a rise point when the input progress value is 0</td>
</tr>
<tr>
<td style="width: 120px; vertical-align: top"><span class="grammar">jump-end</span></td>
<td>the interval ends with a rise point when the input progress value is 1</td>
</tr>
<tr>
<td style="width: 120px; vertical-align: top"><span class="grammar">jump-none</span></td>
<td>all rise points are within the open interval (0..1)</td>
</tr>
<tr>
<td style="width: 120px; vertical-align: top"><span class="grammar">jump-both</span></td>
<td>the interval starts with a rise point when the input progress value is 0,
and ends with a rise point when the input progress value is 1</td>
</tr>
<tr>
<td style="width: 120px; vertical-align: top"><span class="grammar">start</span></td>
<td>equivalent to <span class="grammar">jump-start</span></td>
</tr>
<tr>
<td style="width: 120px; vertical-align: top"><span class="grammar">end</span></td>
<td>equivalent to <span class="grammar">jump-end</span></td>
</tr>
</table>
<p>Examples of step easing functions:</p>
<figure style="display: inline-block">
<img src="easing-stepstart.svg" width="200" alt="jump-start easing function">
<figcaption style="margin-left: 30px" class="grammar">steps(3, jump-start)</figcaption>
</figure>
<figure style="display: inline-block">
<img src="easing-stepend.svg" width="200" alt="jump-end easing function">
<figcaption style="margin-left: 30px" class="grammar">steps(3, jump-end)</figcaption>
</figure>
<figure style="display: inline-block">
<img src="easing-stepnone.svg" width="200" alt="jump-none easing function">
<figcaption style="margin-left: 30px" class="grammar">steps(3, jump-none)</figcaption>
</figure>
<figure style="display: inline-block">
<img src="easing-stepboth.svg" width="200" alt="jump-both easing function">
<figcaption style="margin-left: 30px" class="grammar">steps(3, jump-both)</figcaption>
</figure>
<p><strong>SMIL 3.0 Easing Functions</strong> <span class="grammar" style="font-size: smaller;">&lt;fx-easing-function&gt;</span></br></p>
<p class="grammar">-fx-ease-in | -fx-ease-out | -fx-ease-both</p>
<p>The values have the following meaning:</p>
<table style="margin-left: 40px;">
<tr>
<td style="width: 120px; vertical-align: top"><span class="grammar">-fx-ease-in</span></td>
<td>SMIL 3.0 ease-in function with an acceleration factor of 0.2</td>
</tr>
<tr>
<td style="width: 120px; vertical-align: top"><span class="grammar">-fx-ease-out</span></td>
<td>SMIL 3.0 ease-out function with a deceleration factor of 0.2</td>
</tr>
<tr>
<td style="width: 120px; vertical-align: top"><span class="grammar">-fx-ease-both</span></td>
<td>SMIL 3.0 ease-in/out function with an acceleration and decelaration factor of 0.2</td>
</tr>
</table>
<p>These functions are provided for compatibility with <code>javafx.animation.Interpolator</code>
implementations of SMIL 3.0 cubic bezier easing functions.</p>

<h3><a id="typetextbounds">&lt;text-bounds&gt;</a></h3>
<p>The geometry of text can be measured either in terms of the bounds of
the particular text to be rendered - visual bounds, or as properties
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading