/usr/share/qt5/doc/qtquick/qtquick-statesanimations-animations.html is in qtdeclarative5-doc-html 5.5.1-2ubuntu6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- animations.qdoc -->
<title>Animation and Transitions in Qt Quick | Qt Quick 5.5</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<ul>
<li>Qt 5.5</li>
<li><a href="qtquick-index.html">Qt Quick</a></li>
<li>Animation and Transitions in Qt Quick</li>
<li id="buildversion">Qt 5.5.1 Reference Documentation</li>
</ul>
</div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#animation-and-transitions-types">Animation and Transitions Types</a></li>
<li class="level1"><a href="#triggering-animations">Triggering Animations</a></li>
<li class="level2"><a href="#direct-property-animation">Direct Property Animation</a></li>
<li class="level2"><a href="#using-predefined-targets-and-properties">Using Predefined Targets and Properties</a></li>
<li class="level2"><a href="#transitions-during-state-changes">Transitions during State Changes</a></li>
<li class="level2"><a href="#default-animation-as-behaviors">Default Animation as Behaviors</a></li>
<li class="level1"><a href="#playing-animations-in-parallel-or-in-sequence">Playing Animations in Parallel or in Sequence</a></li>
<li class="level1"><a href="#controlling-animations">Controlling Animations</a></li>
<li class="level2"><a href="#animation-playback">Animation Playback</a></li>
<li class="level2"><a href="#easing">Easing</a></li>
<li class="level2"><a href="#other-animation-types">Other Animation Types</a></li>
<li class="level1"><a href="#sharing-animation-instances">Sharing Animation Instances</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<a name="qml-transition-animations"></a><a name="qml-controlling-animations"></a><a name="qml-easing-animation"></a><h1 class="title">Animation and Transitions in Qt Quick</h1>
<span class="subtitle"></span>
<!-- $$$qtquick-statesanimations-animations.html-description -->
<div class="descr"> <a name="details"></a>
<a name="animation-and-transitions-types"></a>
<h2 id="animation-and-transitions-types">Animation and Transitions Types</h2>
<ul>
<li><a href="qmlexampletoggleswitch.html#transition">Transition</a> - Animates transitions during state changes</li>
<li><a href="qml-qtquick-sequentialanimation.html">SequentialAnimation</a> - Runs animations sequentially</li>
<li><a href="qml-qtquick-parallelanimation.html">ParallelAnimation</a> - Runs animations in parallel</li>
<li><a href="qml-qtquick-behavior.html">Behavior</a> - Specifies a default animation for property changes</li>
<li><a href="qml-qtquick-propertyaction.html">PropertyAction</a> - Sets immediate property changes during animation</li>
<li><a href="qml-qtquick-pauseanimation.html">PauseAnimation</a> - Introduces a pause in an animation</li>
<li><a href="qml-qtquick-smoothedanimation.html">SmoothedAnimation</a> - Allows a property to smoothly track a value</li>
<li><a href="qml-qtquick-springanimation.html">SpringAnimation</a> - Allows a property to track a value in a spring-like motion</li>
<li><a href="qml-qtquick-scriptaction.html">ScriptAction</a> - Runs scripts during an animation</li>
</ul>
<p>Types that animate properties based on data types <div class="table"><table class="annotated">
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-qtquick-anchoranimation.html">AnchorAnimation</a></p></td><td class="tblDescr"><p>Animates changes in anchor values</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-qtquick-coloranimation.html">ColorAnimation</a></p></td><td class="tblDescr"><p>Animates changes in color values</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></p></td><td class="tblDescr"><p>Animates changes in qreal-type values</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-qtquick-parentanimation.html">ParentAnimation</a></p></td><td class="tblDescr"><p>Animates changes in parent values</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-qtquick-pathanimation.html">PathAnimation</a></p></td><td class="tblDescr"><p>Animates an item along a path</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-qtquick-propertyanimation.html">PropertyAnimation</a></p></td><td class="tblDescr"><p>Animates changes in property values</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-qtquick-rotationanimation.html">RotationAnimation</a></p></td><td class="tblDescr"><p>Animates changes in rotation values</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-qtquick-vector3danimation.html">Vector3dAnimation</a></p></td><td class="tblDescr"><p>Animates changes in QVector3d values</p></td></tr>
</table></div>
</p>
<p>Animations are created by applying animation types to property values. Animation types will interpolate property values to create smooth transitions. As well, state transitions may assign animations to state changes.</p>
<p>To create an animation, use an appropriate animation type for the type of the property that is to be animated, and apply the animation depending on the type of behavior that is required.</p>
<a name="triggering-animations"></a>
<h2 id="triggering-animations">Triggering Animations</h2>
<p>There are several ways of setting animation to an object.</p>
<a name="direct-property-animation"></a>
<h3 >Direct Property Animation</h3>
<p>Animations are created by applying animation objects to property values to gradually change the properties over time. These <i>property animations</i> apply smooth movements by interpolating values between property value changes. Property animations provide timing controls and allows different interpolations through <a href="qtquick-statesanimations-animations.html#qml-easing-animation">easing curves</a>.</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
<span class="name">id</span>: <span class="name">flashingblob</span>
<span class="name">width</span>: <span class="number">75</span>; <span class="name">height</span>: <span class="number">75</span>
<span class="name">color</span>: <span class="string">"blue"</span>
<span class="name">opacity</span>: <span class="number">1.0</span>
<span class="type"><a href="qml-qtquick-mousearea.html">MouseArea</a></span> {
<span class="name">anchors</span>.fill: <span class="name">parent</span>
<span class="name">onClicked</span>: {
<span class="name">animateColor</span>.<span class="name">start</span>()
<span class="name">animateOpacity</span>.<span class="name">start</span>()
}
}
<span class="type"><a href="qml-qtquick-propertyanimation.html">PropertyAnimation</a></span> {<span class="name">id</span>: <span class="name">animateColor</span>; <span class="name">target</span>: <span class="name">flashingblob</span>; <span class="name">properties</span>: <span class="string">"color"</span>; <span class="name">to</span>: <span class="string">"green"</span>; <span class="name">duration</span>: <span class="number">100</span>}
<span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> {
<span class="name">id</span>: <span class="name">animateOpacity</span>
<span class="name">target</span>: <span class="name">flashingblob</span>
<span class="name">properties</span>: <span class="string">"opacity"</span>
<span class="name">from</span>: <span class="number">0.99</span>
<span class="name">to</span>: <span class="number">1.0</span>
<span class="name">loops</span>: <span class="name">Animation</span>.<span class="name">Infinite</span>
<span class="type">easing</span> {<span class="name">type</span>: <span class="name">Easing</span>.<span class="name">OutBack</span>; <span class="name">overshoot</span>: <span class="number">500</span>}
}
}</pre>
<p>Specialized property animation types have more efficient implementations than the <a href="qtquick-animation-example.html#propertyanimation">PropertyAnimation</a> type. They are for setting animations to different QML types such as <code>int</code>, <code>color</code>, and rotations. Similarly, the <a href="qml-qtquick-parentanimation.html">ParentAnimation</a> can animate parent changes.</p>
<p>See the <a href="qtquick-statesanimations-animations.html#qml-controlling-animations">Controlling Animations</a> section for more information about the different animation properties.</p>
<a name="using-predefined-targets-and-properties"></a>
<h3 >Using Predefined Targets and Properties</h3>
<p>In the previous example, the <a href="qtquick-animation-example.html#propertyanimation">PropertyAnimation</a> and <a href="qml-qtquick-numberanimation.html">NumberAnimation</a> objects needed to specify particular <a href="qml-qtquick-propertyanimation.html#target-prop">target</a> and <a href="qml-qtquick-propertyanimation.html#properties-prop">properties</a> values to specify the objects and properties that should be animated. This can be avoided by using the <i><Animation> on <Property></i> syntax, which specifies the animation is to be applied as a <i>property value source</i>.</p>
<p>Below are two <a href="qtquick-animation-example.html#propertyanimation">PropertyAnimation</a> objects that are specified using this syntax:</p>
<pre class="qml">import QtQuick 2.0
<span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
<span class="name">id</span>: <span class="name">rect</span>
<span class="name">width</span>: <span class="number">100</span>; <span class="name">height</span>: <span class="number">100</span>
<span class="name">color</span>: <span class="string">"red"</span>
PropertyAnimation on <span class="name">x</span> { <span class="name">to</span>: <span class="number">100</span> }
PropertyAnimation on <span class="name">y</span> { <span class="name">to</span>: <span class="number">100</span> }
}</pre>
<p>The animation starts as soon as the rectangle is loaded, and will automatically be applied to its <code>x</code> and <code>y</code> values. Since the <i><Animation> on <Property></i> syntax has been used, it is not necessary to set the <a href="qml-qtquick-propertyanimation.html#target-prop">target</a> value of the <a href="qtquick-animation-example.html#propertyanimation">PropertyAnimation</a> objects to <code>rect</code>, and neither is it necessary to set the <a href="qml-qtquick-propertyanimation.html#property-prop">property</a> values to <code>x</code> and <code>y</code>.</p>
<p>This can also be used by <a href="qtquick-statesanimations-animations.html#playing-animations-in-parallel-or-in-sequence">grouped animations</a> to ensure that all animations within a group are applied to the same property. For example, the previous example could instead use <a href="qml-qtquick-sequentialanimation.html">SequentialAnimation</a> to animate the rectangle's <code>color</code> first to yellow, then to blue:</p>
<pre class="qml">import QtQuick 2.0
<span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
<span class="name">width</span>: <span class="number">100</span>; <span class="name">height</span>: <span class="number">100</span>
<span class="name">color</span>: <span class="string">"red"</span>
SequentialAnimation on <span class="name">color</span> {
<span class="type"><a href="qml-qtquick-coloranimation.html">ColorAnimation</a></span> { <span class="name">to</span>: <span class="string">"yellow"</span>; <span class="name">duration</span>: <span class="number">1000</span> }
<span class="type"><a href="qml-qtquick-coloranimation.html">ColorAnimation</a></span> { <span class="name">to</span>: <span class="string">"blue"</span>; <span class="name">duration</span>: <span class="number">1000</span> }
}
}</pre>
<p>Since the <a href="qml-qtquick-sequentialanimation.html">SequentialAnimation</a> object has been specified on the <code>color</code> property using the <i><Animation> on <Property></i> syntax, its child <a href="qtquick-animation-example.html#coloranimation">ColorAnimation</a> objects are also automatically applied to this property and do not need to specify <a href="qml-qtquick-propertyanimation.html#target-prop">target</a> or <a href="qml-qtquick-propertyanimation.html#property-prop">property</a> animation values.</p>
<a name="transitions-during-state-changes"></a>
<h3 >Transitions during State Changes</h3>
<p><a href="qml-qtquick-state.html">Qt Quick States</a> are property configurations where a property may have different values to reflect different states. State changes introduce abrupt property changes; animations smooth transitions to produce visually appealing state changes.</p>
<p>The <a href="qmlexampletoggleswitch.html#transition">Transition</a> type can contain animation types to interpolate property changes caused by state changes. To assign the transition to an object, bind it to the <code>transitions</code> property.</p>
<p>A button might have two states, the <code>pressed</code> state when the user clicks on the button and a <code>released</code> state when the user releases the button. We can assign different property configurations for each state. A transition would animate the change from the <code>pressed</code> state to the <code>released</code> state. Likewise, there would be an animation during the change from the <code>released</code> state to the <code>pressed</code> state.</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
<span class="name">width</span>: <span class="number">75</span>; <span class="name">height</span>: <span class="number">75</span>
<span class="name">id</span>: <span class="name">button</span>
<span class="name">state</span>: <span class="string">"RELEASED"</span>
<span class="type"><a href="qml-qtquick-mousearea.html">MouseArea</a></span> {
<span class="name">anchors</span>.fill: <span class="name">parent</span>
<span class="name">onPressed</span>: <span class="name">button</span>.<span class="name">state</span> <span class="operator">=</span> <span class="string">"PRESSED"</span>
<span class="name">onReleased</span>: <span class="name">button</span>.<span class="name">state</span> <span class="operator">=</span> <span class="string">"RELEASED"</span>
}
<span class="name">states</span>: [
<span class="type"><a href="qml-qtquick-state.html">State</a></span> {
<span class="name">name</span>: <span class="string">"PRESSED"</span>
<span class="type"><a href="qml-qtquick-propertychanges.html">PropertyChanges</a></span> { <span class="name">target</span>: <span class="name">button</span>; <span class="name">color</span>: <span class="string">"lightblue"</span>}
},
<span class="type"><a href="qml-qtquick-state.html">State</a></span> {
<span class="name">name</span>: <span class="string">"RELEASED"</span>
<span class="type"><a href="qml-qtquick-propertychanges.html">PropertyChanges</a></span> { <span class="name">target</span>: <span class="name">button</span>; <span class="name">color</span>: <span class="string">"lightsteelblue"</span>}
}
]
<span class="name">transitions</span>: [
<span class="type"><a href="qml-qtquick-transition.html">Transition</a></span> {
<span class="name">from</span>: <span class="string">"PRESSED"</span>
<span class="name">to</span>: <span class="string">"RELEASED"</span>
<span class="type"><a href="qml-qtquick-coloranimation.html">ColorAnimation</a></span> { <span class="name">target</span>: <span class="name">button</span>; <span class="name">duration</span>: <span class="number">100</span>}
},
<span class="type"><a href="qml-qtquick-transition.html">Transition</a></span> {
<span class="name">from</span>: <span class="string">"RELEASED"</span>
<span class="name">to</span>: <span class="string">"PRESSED"</span>
<span class="type"><a href="qml-qtquick-coloranimation.html">ColorAnimation</a></span> { <span class="name">target</span>: <span class="name">button</span>; <span class="name">duration</span>: <span class="number">100</span>}
}
]
}</pre>
<p>Binding the <code>to</code> and <code>from</code> properties to the state's name will assign that particular transition to the state change. For simple or symmetric transitions, setting the to <code>to</code> property to the wild card symbol, "<code>*</code>", denotes that the transition applies to any state change.</p>
<pre class="qml"> <span class="name">transitions</span>:
<span class="name">Transition</span> {
<span class="name">to</span>: <span class="string">"*"</span>
<span class="type"><a href="qml-qtquick-coloranimation.html">ColorAnimation</a></span> { <span class="name">target</span>: <span class="name">button</span>; <span class="name">duration</span>: <span class="number">100</span>}
}</pre>
<a name="default-animation-as-behaviors"></a>
<h3 >Default Animation as Behaviors</h3>
<p>Default property animations are set using <i>behavior animations</i>. Animations declared in <a href="qml-qtquick-behavior.html">Behavior</a> types apply to the property and animates any property value changes. However, Behavior types have an <code>enabled</code> property to purposely enable or disable the behavior animations.</p>
<p>A ball component might have a behavior animation assigned to its <code>x</code>, <code>y</code>, and <code>color</code> properties. The behavior animation could be set up to simulate an elastic effect. In effect, this behavior animation would apply the elastic effect to the properties whenever the ball moves.</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
<span class="name">width</span>: <span class="number">75</span>; <span class="name">height</span>: <span class="number">75</span>; <span class="name">radius</span>: <span class="name">width</span>
<span class="name">id</span>: <span class="name">ball</span>
<span class="name">color</span>: <span class="string">"salmon"</span>
Behavior on <span class="name">x</span> {
<span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> {
<span class="name">id</span>: <span class="name">bouncebehavior</span>
<span class="type">easing</span> {
<span class="name">type</span>: <span class="name">Easing</span>.<span class="name">OutElastic</span>
<span class="name">amplitude</span>: <span class="number">1.0</span>
<span class="name">period</span>: <span class="number">0.5</span>
}
}
}
Behavior on <span class="name">y</span> {
<span class="name">animation</span>: <span class="name">bouncebehavior</span>
}
<span class="type"><a href="qml-qtquick-behavior.html">Behavior</a></span> {
<span class="type"><a href="qml-qtquick-coloranimation.html">ColorAnimation</a></span> { <span class="name">target</span>: <span class="name">ball</span>; <span class="name">duration</span>: <span class="number">100</span> }
}
}</pre>
<p>There are several methods of assigning behavior animations to properties. The <code>Behavior on <property></code> declaration is a convenient way of assigning a behavior animation onto a property.</p>
<p>See the <a href="qtquick-animation-example.html">Qt Quick Examples - Animation</a> for a demonstration of behavioral animations.</p>
<a name="playing-animations-in-parallel-or-in-sequence"></a>
<h2 id="playing-animations-in-parallel-or-in-sequence">Playing Animations in Parallel or in Sequence</h2>
<p>Animations can run <i>in parallel</i> or <i>in sequence</i>. Parallel animations will play a group of animations at the same time while sequential animations play a group of animations in order: one after the other. Grouping animations in <a href="qml-qtquick-sequentialanimation.html">SequentialAnimation</a> and <a href="qml-qtquick-parallelanimation.html">ParallelAnimation</a> will play the animations in sequence or in parallel.</p>
<p>A banner component may have several icons or slogans to display, one after the other. The <code>opacity</code> property could transform to <code>1.0</code> denoting an opaque object. Using the <a href="qml-qtquick-sequentialanimation.html">SequentialAnimation</a> type, the opacity animations will play after the preceding animation finishes. The <a href="qml-qtquick-parallelanimation.html">ParallelAnimation</a> type will play the animations at the same time.</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
<span class="name">id</span>: <span class="name">banner</span>
<span class="name">width</span>: <span class="number">150</span>; <span class="name">height</span>: <span class="number">100</span>; <span class="name">border</span>.color: <span class="string">"black"</span>
<span class="type"><a href="qml-qtquick-column.html">Column</a></span> {
<span class="name">anchors</span>.centerIn: <span class="name">parent</span>
<span class="type"><a href="qml-qtquick-text.html">Text</a></span> {
<span class="name">id</span>: <span class="name">code</span>
<span class="name">text</span>: <span class="string">"Code less."</span>
<span class="name">opacity</span>: <span class="number">0.01</span>
}
<span class="type"><a href="qml-qtquick-text.html">Text</a></span> {
<span class="name">id</span>: <span class="name">create</span>
<span class="name">text</span>: <span class="string">"Create more."</span>
<span class="name">opacity</span>: <span class="number">0.01</span>
}
<span class="type"><a href="qml-qtquick-text.html">Text</a></span> {
<span class="name">id</span>: <span class="name">deploy</span>
<span class="name">text</span>: <span class="string">"Deploy everywhere."</span>
<span class="name">opacity</span>: <span class="number">0.01</span>
}
}
<span class="type"><a href="qml-qtquick-mousearea.html">MouseArea</a></span> {
<span class="name">anchors</span>.fill: <span class="name">parent</span>
<span class="name">onPressed</span>: <span class="name">playbanner</span>.<span class="name">start</span>()
}
<span class="type"><a href="qml-qtquick-sequentialanimation.html">SequentialAnimation</a></span> {
<span class="name">id</span>: <span class="name">playbanner</span>
<span class="name">running</span>: <span class="number">false</span>
<span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> { <span class="name">target</span>: <span class="name">code</span>; <span class="name">property</span>: <span class="string">"opacity"</span>; <span class="name">to</span>: <span class="number">1.0</span>; <span class="name">duration</span>: <span class="number">200</span>}
<span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> { <span class="name">target</span>: <span class="name">create</span>; <span class="name">property</span>: <span class="string">"opacity"</span>; <span class="name">to</span>: <span class="number">1.0</span>; <span class="name">duration</span>: <span class="number">200</span>}
<span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> { <span class="name">target</span>: <span class="name">deploy</span>; <span class="name">property</span>: <span class="string">"opacity"</span>; <span class="name">to</span>: <span class="number">1.0</span>; <span class="name">duration</span>: <span class="number">200</span>}
}
}</pre>
<p>Once individual animations are placed into a <a href="qml-qtquick-sequentialanimation.html">SequentialAnimation</a> or <a href="qml-qtquick-parallelanimation.html">ParallelAnimation</a>, they can no longer be started and stopped independently. The sequential or parallel animation must be started and stopped as a group.</p>
<p>The <a href="qml-qtquick-sequentialanimation.html">SequentialAnimation</a> type is also useful for playing <a href="qtquick-statesanimations-animations.html#qml-transition-animations">transition animations</a> because animations are played in parallel inside transitions.</p>
<a name="controlling-animations"></a>
<h2 id="controlling-animations">Controlling Animations</h2>
<p>There are different methods to control animations.</p>
<a name="animation-playback"></a>
<h3 >Animation Playback</h3>
<p>All animation types inherit from the <a href="qml-qtquick-animation.html">Animation</a> type. It is not possible to create <a href="qml-qtquick-animation.html">Animation</a> objects; instead, this type provides the essential properties and methods for animation types. Animation types have <code>start()</code>, <code>stop()</code>, <code>resume()</code>, <code>pause()</code>, <code>restart()</code>, and <code>complete()</code> -- all of these methods control the execution of animations.</p>
<a name="easing"></a>
<h3 >Easing</h3>
<p>Easing curves define how the animation will interpolate between the start value and the end value. Different easing curves might go beyond the defined range of interpolation. The easing curves simplify the creation of animation effects such as bounce effects, acceleration, deceleration, and cyclical animations.</p>
<p>A QML object may have different easing curve for each property animation. There are also different parameters to control the curve, some of which are exclusive to a particular curve. For more information about the easing curves, visit the <a href="qml-qtquick-propertyanimation.html#easing.type-prop">easing</a> documentation.</p>
<p>The easing example visually demonstrates each of the different easing types.</p>
<a name="other-animation-types"></a>
<h3 >Other Animation Types</h3>
<p>In addition, QML provides several other types useful for animation:</p>
<ul>
<li><a href="qml-qtquick-pauseanimation.html">PauseAnimation</a>: enables pauses during animations</li>
<li><a href="qml-qtquick-scriptaction.html">ScriptAction</a>: allows JavaScript to be executed during an animation, and can be used together with <a href="qml-qtquick-statechangescript.html">StateChangeScript</a> to reused existing scripts</li>
<li><a href="qml-qtquick-propertyaction.html">PropertyAction</a>: changes a property <i>immediately</i> during an animation, without animating the property change</li>
</ul>
<p>These are specialized animation types that animate different property types</p>
<ul>
<li><a href="qml-qtquick-smoothedanimation.html">SmoothedAnimation</a>: a specialized <a href="qml-qtquick-numberanimation.html">NumberAnimation</a> that provides smooth changes in animation when the target value changes</li>
<li><a href="qml-qtquick-springanimation.html">SpringAnimation</a>: provides a spring-like animation with specialized attributes such as <a href="qml-qtquick-springanimation.html#mass-prop">mass</a>, <a href="qml-qtquick-springanimation.html#damping-prop">damping</a> and <a href="qml-qtquick-springanimation.html#epsilon-prop">epsilon</a></li>
<li><a href="qml-qtquick-parentanimation.html">ParentAnimation</a>: used for animating a parent change (see <a href="qml-qtquick-parentchange.html">ParentChange</a>)</li>
<li><a href="qml-qtquick-anchoranimation.html">AnchorAnimation</a>: used for animating an anchor change (see <a href="qml-qtquick-anchorchanges.html">AnchorChanges</a>)</li>
</ul>
<a name="sharing-animation-instances"></a>
<h2 id="sharing-animation-instances">Sharing Animation Instances</h2>
<p>Sharing animation instances between Transitions or Behaviors is not supported, and may lead to undefined behavior. In the following example, changes to the Rectangle's position will most likely not be correctly animated.</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
<span class="comment">// NOT SUPPORTED: this will not work correctly as both Behaviors</span>
<span class="comment">// try to control a single animation instance</span>
<span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> { <span class="name">id</span>: <span class="name">anim</span>; <span class="name">duration</span>: <span class="number">300</span>; <span class="name">easing</span>.type: <span class="name">Easing</span>.<span class="name">InBack</span> }
Behavior on <span class="name">x</span> { <span class="name">animation</span>: <span class="name">anim</span> }
Behavior on <span class="name">y</span> { <span class="name">animation</span>: <span class="name">anim</span> }
}</pre>
<p>The easiest fix is to repeat the <a href="qml-qtquick-numberanimation.html">NumberAnimation</a> for both Behaviors. If the repeated animation is rather complex, you might also consider creating a custom animation component and assigning an instance to each Behavior, for example:</p>
<pre class="qml"><span class="comment">// MyNumberAnimation.qml</span>
<span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> { <span class="name">id</span>: <span class="name">anim</span>; <span class="name">duration</span>: <span class="number">300</span>; <span class="name">easing</span>.type: <span class="name">Easing</span>.<span class="name">InBack</span> }</pre>
<pre class="qml"><span class="comment">// main.qml</span>
<span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
Behavior on <span class="name">x</span> { <span class="type">MyNumberAnimation</span> {} }
Behavior on <span class="name">y</span> { <span class="type">MyNumberAnimation</span> {} }
}</pre>
</div>
<p><b>See also </b><a href="qtquick-animation-example.html">Qt Quick Examples - Animation</a>.</p>
<!-- @@@qtquick-statesanimations-animations.html -->
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2015 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners.<br> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. </p>
</div>
</body>
</html>
|