Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

Commit efc2a07

Browse files
committed
Updated docs
1 parent 70fe5c1 commit efc2a07

File tree

4 files changed

+68
-51
lines changed

4 files changed

+68
-51
lines changed

README.md

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,7 @@ In contrast to standard `UIView` animations, Advance animations are applied on e
1717
```swift
1818
let view = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
1919

20-
let spring = Spring(boundTo: view, keyPath: \.center)
21-
22-
/// The view's center will realistically animate to the new value.
23-
spring.target = CGPoint(x: 300, y: 200)
24-
```
25-
26-
27-
```swift
28-
let view = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
29-
20+
/// Animators coordinate animations to drive changes to a value.
3021
let sizeAnimator = Animator(boundTo: view, keyPath: \.bounds.size)
3122

3223
/// Spring physics will move the view's size to the new value.
@@ -40,6 +31,17 @@ sizeAnimator.decay(drag: 2.0)
4031

4132
```
4233

34+
```swift
35+
let view = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
36+
37+
/// Springs are... springs. That's all they do.
38+
let spring = Spring(boundTo: view, keyPath: \.center)
39+
40+
/// The view's center will realistically animate to the new value.
41+
spring.target = CGPoint(x: 300, y: 200)
42+
```
43+
44+
4345
### Animator
4446

4547
`Animator` drives changes to a value over time using animations (conforming to the `Animation` protocol).
@@ -67,7 +69,7 @@ boundsAnimator.decay(initialVelocity: CGRect(x: 30, y: 30, width: 30, height: 30
6769

6870
```
6971

70-
You won't commonly need to initialize animations directly.
72+
Each of these methods returns an `AnimationRunner<Value>` instance, which can be used to add completion handlers, wire up additional observers for the running animation, etc.
7173

7274
### Simulator / Spring
7375
`Simulator` uses a physics-based simulation to realistically model changes to a value over time.
@@ -86,6 +88,7 @@ simulator.observe { value in
8688
}
8789
```
8890

91+
#### Spring
8992
`Spring` 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.
9093

9194
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.
@@ -108,6 +111,14 @@ spring.reset(to: 0.5)
108111

109112
```
110113

114+
#### Simulation Functions
115+
116+
Simulations are powered by a **Simulation Function**. These functions compute the forces that should effect the value for every frame, and control *convergence* (or: when the simulation should come to rest). The included simulation functions are:
117+
- `SpringFunction`
118+
- `DecayFunction`
119+
- `GravityFunction`
120+
121+
111122
### Animations
112123

113124
Values conforming to the `VectorConvertible` protocol can be animated by Advance. Conforming types can be converted to and from a `Vector` implementation.
@@ -134,13 +145,9 @@ Basic animations use a timing function to control the pacing of the value's chan
134145

135146

136147
#### Simulated animations
137-
`SimulatedAnimation` use a physics-based approach to model changes to a value over time. This allows for realistic animations that model real-world behavior. `SimulatedAnimation` allows you to use the same simulation functions that power `Simulator` with an `Animator`.
138-
139-
Simulated animations are powered by a **Simulation Function**. These functions compute the forces that should effect the animated value for every frame, and control *convergence* (or: when the simulation should come to rest). The included simulation functions are:
140-
- `SpringFunction`
141-
- `DecayFunction`
142-
- `GravityFunction`
148+
`SimulatedAnimation` uses a physics-based approach to model changes to a value over time, enabling realistic animations that model real-world behavior. `SimulatedAnimation` allows you to use simulation functions as animations (most commonly with an `Animator` instance).
143149

150+
#### Creating animations
144151

145152
Convenience extensions make it easy to generate animations from `VectorConvertible` types.
146153

docs/docsets/Advance.docset/Contents/Resources/Documents/index.html

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,7 @@ <h2 id='usage' class='heading'>Usage</h2>
227227
<p>In contrast to standard <code>UIView</code> animations, Advance animations are applied on every frame (using <code>CADisplayLink</code> on iOS).</p>
228228
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">view</span> <span class="o">=</span> <span class="kt">UIView</span><span class="p">(</span><span class="nv">frame</span><span class="p">:</span> <span class="kt">CGRect</span><span class="p">(</span><span class="nv">x</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">y</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">width</span><span class="p">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nv">height</span><span class="p">:</span> <span class="mi">100</span><span class="p">))</span>
229229

230-
<span class="k">let</span> <span class="nv">spring</span> <span class="o">=</span> <span class="kt">Spring</span><span class="p">(</span><span class="nv">boundTo</span><span class="p">:</span> <span class="n">view</span><span class="p">,</span> <span class="nv">keyPath</span><span class="p">:</span> <span class="err">\</span><span class="o">.</span><span class="n">center</span><span class="p">)</span>
231-
232-
<span class="c1">/// The view's center will realistically animate to the new value.</span>
233-
<span class="n">spring</span><span class="o">.</span><span class="n">target</span> <span class="o">=</span> <span class="kt">CGPoint</span><span class="p">(</span><span class="nv">x</span><span class="p">:</span> <span class="mi">300</span><span class="p">,</span> <span class="nv">y</span><span class="p">:</span> <span class="mi">200</span><span class="p">)</span>
234-
</code></pre>
235-
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">view</span> <span class="o">=</span> <span class="kt">UIView</span><span class="p">(</span><span class="nv">frame</span><span class="p">:</span> <span class="kt">CGRect</span><span class="p">(</span><span class="nv">x</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">y</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">width</span><span class="p">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nv">height</span><span class="p">:</span> <span class="mi">100</span><span class="p">))</span>
236-
230+
<span class="c1">/// Animators coordinate animations to drive changes to a value.</span>
237231
<span class="k">let</span> <span class="nv">sizeAnimator</span> <span class="o">=</span> <span class="kt">Animator</span><span class="p">(</span><span class="nv">boundTo</span><span class="p">:</span> <span class="n">view</span><span class="p">,</span> <span class="nv">keyPath</span><span class="p">:</span> <span class="err">\</span><span class="o">.</span><span class="n">bounds</span><span class="o">.</span><span class="n">size</span><span class="p">)</span>
238232

239233
<span class="c1">/// Spring physics will move the view's size to the new value.</span>
@@ -245,6 +239,14 @@ <h2 id='usage' class='heading'>Usage</h2>
245239
<span class="c1">/// animation, and a decay function will slowly bring movement to a stop.</span>
246240
<span class="n">sizeAnimator</span><span class="o">.</span><span class="nf">decay</span><span class="p">(</span><span class="nv">drag</span><span class="p">:</span> <span class="mf">2.0</span><span class="p">)</span>
247241

242+
</code></pre>
243+
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">view</span> <span class="o">=</span> <span class="kt">UIView</span><span class="p">(</span><span class="nv">frame</span><span class="p">:</span> <span class="kt">CGRect</span><span class="p">(</span><span class="nv">x</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">y</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">width</span><span class="p">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nv">height</span><span class="p">:</span> <span class="mi">100</span><span class="p">))</span>
244+
245+
<span class="c1">/// Springs are... springs. That's all they do.</span>
246+
<span class="k">let</span> <span class="nv">spring</span> <span class="o">=</span> <span class="kt">Spring</span><span class="p">(</span><span class="nv">boundTo</span><span class="p">:</span> <span class="n">view</span><span class="p">,</span> <span class="nv">keyPath</span><span class="p">:</span> <span class="err">\</span><span class="o">.</span><span class="n">center</span><span class="p">)</span>
247+
248+
<span class="c1">/// The view's center will realistically animate to the new value.</span>
249+
<span class="n">spring</span><span class="o">.</span><span class="n">target</span> <span class="o">=</span> <span class="kt">CGPoint</span><span class="p">(</span><span class="nv">x</span><span class="p">:</span> <span class="mi">300</span><span class="p">,</span> <span class="nv">y</span><span class="p">:</span> <span class="mi">200</span><span class="p">)</span>
248250
</code></pre>
249251
<h3 id='animator' class='heading'>Animator</h3>
250252

@@ -271,7 +273,7 @@ <h3 id='animator' class='heading'>Animator</h3>
271273

272274
</code></pre>
273275

274-
<p>You won&rsquo;t commonly need to initialize animations directly.</p>
276+
<p>Each of these methods returns an <code><a href="Classes/AnimationRunner.html">AnimationRunner&lt;Value&gt;</a></code> instance, which can be used to add completion handlers, wire up additional observers for the running animation, etc.</p>
275277
<h3 id='simulator-spring' class='heading'>Simulator / Spring</h3>
276278

277279
<p><code><a href="Classes/Simulator.html">Simulator</a></code> uses a physics-based simulation to realistically model changes to a value over time.</p>
@@ -287,6 +289,7 @@ <h3 id='simulator-spring' class='heading'>Simulator / Spring</h3>
287289
<span class="c1">/// Apply the new value.</span>
288290
<span class="p">}</span>
289291
</code></pre>
292+
<h4 id='spring' class='heading'>Spring</h4>
290293

291294
<p><code><a href="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>
292295

@@ -307,6 +310,15 @@ <h3 id='simulator-spring' class='heading'>Simulator / Spring</h3>
307310
<span class="n">spring</span><span class="o">.</span><span class="nf">reset</span><span class="p">(</span><span class="nv">to</span><span class="p">:</span> <span class="mf">0.5</span><span class="p">)</span>
308311

309312
</code></pre>
313+
<h4 id='simulation-functions' class='heading'>Simulation Functions</h4>
314+
315+
<p>Simulations are powered by a <strong>Simulation Function</strong>. These functions compute the forces that should effect the value for every frame, and control <em>convergence</em> (or: when the simulation should come to rest). The included simulation functions are:</p>
316+
317+
<ul>
318+
<li><code><a href="Structs/SpringFunction.html">SpringFunction</a></code></li>
319+
<li><code><a href="Structs/DecayFunction.html">DecayFunction</a></code></li>
320+
<li><code><a href="Structs/GravityFunction.html">GravityFunction</a></code></li>
321+
</ul>
310322
<h3 id='animations' class='heading'>Animations</h3>
311323

312324
<p>Values conforming to the <code><a href="Protocols/VectorConvertible.html">VectorConvertible</a></code> protocol can be animated by Advance. Conforming types can be converted to and from a <code><a href="Protocols/Vector.html">Vector</a></code> implementation.</p>
@@ -332,15 +344,8 @@ <h5 id='timing-functions' class='heading'>Timing Functions</h5>
332344
</ul>
333345
<h4 id='simulated-animations' class='heading'>Simulated animations</h4>
334346

335-
<p><code><a href="Structs/SimulatedAnimation.html">SimulatedAnimation</a></code> use a physics-based approach to model changes to a value over time. This allows for realistic animations that model real-world behavior. <code><a href="Structs/SimulatedAnimation.html">SimulatedAnimation</a></code> allows you to use the same simulation functions that power <code><a href="Classes/Simulator.html">Simulator</a></code> with an <code><a href="Classes/Animator.html">Animator</a></code>.</p>
336-
337-
<p>Simulated animations are powered by a <strong>Simulation Function</strong>. These functions compute the forces that should effect the animated value for every frame, and control <em>convergence</em> (or: when the simulation should come to rest). The included simulation functions are:</p>
338-
339-
<ul>
340-
<li><code><a href="Structs/SpringFunction.html">SpringFunction</a></code></li>
341-
<li><code><a href="Structs/DecayFunction.html">DecayFunction</a></code></li>
342-
<li><code><a href="Structs/GravityFunction.html">GravityFunction</a></code></li>
343-
</ul>
347+
<p><code><a href="Structs/SimulatedAnimation.html">SimulatedAnimation</a></code> uses a physics-based approach to model changes to a value over time, enabling realistic animations that model real-world behavior. <code><a href="Structs/SimulatedAnimation.html">SimulatedAnimation</a></code> allows you to use simulation functions as animations (most commonly with an <code><a href="Classes/Animator.html">Animator</a></code> instance).</p>
348+
<h4 id='creating-animations' class='heading'>Creating animations</h4>
344349

345350
<p>Convenience extensions make it easy to generate animations from <code><a href="Protocols/VectorConvertible.html">VectorConvertible</a></code> types.</p>
346351
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">springAnimation</span> <span class="o">=</span> <span class="kt">CGPoint</span><span class="o">.</span><span class="n">zero</span><span class="o">.</span><span class="nf">springAnimation</span><span class="p">(</span><span class="nv">to</span><span class="p">:</span> <span class="kt">CGPoint</span><span class="p">(</span><span class="nv">x</span><span class="p">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nv">y</span><span class="p">:</span> <span class="mi">100</span><span class="p">))</span>

docs/docsets/Advance.tgz

134 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)