You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 2, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ The current velocity of the value is available though the `velocity` property, m
48
48
49
49
A set of extensions make it easy to kick off animations on an animator:
50
50
51
-
```
51
+
```swift
52
52
let view =UIView()
53
53
let boundsAnimator =Animator(boundTo: view, keyPath: \.bounds)
54
54
@@ -78,7 +78,7 @@ In contrast, `Simulator` is a focused class that is useful for scenarios where y
78
78
79
79
`Simulator` conforms to `Observable`, so you can easily be notified when the simulated value changes.
80
80
81
-
```
81
+
```swift
82
82
let function =GravityFunction(target: CGPoint(20, 20).vector)
83
83
let simulator =Simulator(function: function, value: CGPoint.zero)
84
84
simulator.observe { value in
@@ -90,7 +90,7 @@ simulator.observe { value in
90
90
91
91
Convenience extensions provide full access to the underlying spring simulation (target, tension, damping, velocity, etc) at any time: even while the simulation is in progress.
92
92
93
-
```
93
+
```swift
94
94
let spring =Spring(boundTo: view, keyPath: \.alpha)
95
95
spring.target=0.5
96
96
@@ -111,7 +111,7 @@ spring.reset(to: 0.5)
111
111
### Animations
112
112
113
113
Values conforming to the `VectorConvertible` protocol can be animated by Advance. Conforming types can be converted to and from a `Vector` implementation.
<p>The current velocity of the value is available though the <code>velocity</code> property, making it easy to transition between animations of different types while maintaining fluid motion.</p>
254
254
255
255
<p>A set of extensions make it easy to kick off animations on an animator:</p>
<p>In contrast, <code><ahref="Classes/Simulator.html">Simulator</a></code> is a focused class that is useful for scenarios where you need direct access to a running simulation. This might occur in a UI where the user’s scroll position drives changes to a spring’s tension, for example. It would be impractical to create and start a new animation every time the simulation needs to change. A <code><ahref="Classes/Simulator.html">Simulator</a></code> instance provides mutable access to the <code>function</code> property (containing the underlying function that is driving the simulation), along with the current state of the simulation (value and velocity).</p>
282
282
283
283
<p><code><ahref="Classes/Simulator.html">Simulator</a></code> conforms to <code><ahref="Protocols/Observable.html">Observable</a></code>, so you can easily be notified when the simulated value changes.</p>
<p><code><ahref="Simulation.html#/s:7Advance6Springa">Spring</a></code> is a specialized simulator that uses a spring function. If all you are after is a simple spring to animate a value, this is what you want.</p>
292
292
293
293
<p>Convenience extensions provide full access to the underlying spring simulation (target, tension, damping, velocity, etc) at any time: even while the simulation is in progress.</p>
spring.tension = 30.0/// The strength of the spring
299
-
spring.damping = 2.0/// The resistance (drag) that the spring encounters
300
-
spring.threshold = 0.1/// The maximum delta between the current value and the spring's target (for each component) for which the simulation can enter a converged state.
297
+
<spanclass="c1">/// Spring values can be adjusted at any time.</span>
298
+
<spanclass="n">spring</span><spanclass="o">.</span><spanclass="n">tension</span><spanclass="o">=</span><spanclass="mf">30.0</span><spanclass="c1">/// The strength of the spring</span>
299
+
<spanclass="n">spring</span><spanclass="o">.</span><spanclass="n">damping</span><spanclass="o">=</span><spanclass="mf">2.0</span><spanclass="c1">/// The resistance (drag) that the spring encounters</span>
300
+
<spanclass="n">spring</span><spanclass="o">.</span><spanclass="n">threshold</span><spanclass="o">=</span><spanclass="mf">0.1</span><spanclass="c1">/// The maximum delta between the current value and the spring's target (for each component) for which the simulation can enter a converged state.</span>
301
301
302
-
/// Update the simulation state at any time.
303
-
spring.velocity = 6.5
304
-
spring.value = 0.2
302
+
<spanclass="c1">/// Update the simulation state at any time.</span>
/// Sets the spring's target and the current simulation value, and removes all velocity. This causes the spring to converge at the given value.
307
-
spring.reset(to: 0.5)
306
+
<spanclass="c1">/// Sets the spring's target and the current simulation value, and removes all velocity. This causes the spring to converge at the given value.</span>
<p>Values conforming to the <code><ahref="Protocols/VectorConvertible.html">VectorConvertible</a></code> protocol can be animated by Advance. Conforming types can be converted to and from a <code><ahref="Protocols/Vector.html">Vector</a></code> implementation.</p>
<p>Convenience extensions make it easy to generate animations from <code><ahref="Protocols/VectorConvertible.html">VectorConvertible</a></code> types.</p>
0 commit comments