Skip to content

Commit 69548cd

Browse files
committed
Updated documentation
1 parent e5669e9 commit 69548cd

File tree

5 files changed

+59
-106
lines changed

5 files changed

+59
-106
lines changed

README.md

+59-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ You can think of it as `UITableView` but with several differences:
2626
|--- |--------------------------------------------------------------------------------- |
2727
| 🕺 | Create complex layout without the boilerplate required by view recyling of `UICollectionView` or `UITableView`. |
2828
| 🧩 | Simplify your architecture by thinking each screen as a separate-indipendent `UIVIewController`. |
29-
| 🌈 | Animate show/hide and resize of rows easily! |
29+
| 🌈 | Animate show/hide and resize of rows easily even with custom animations! |
3030
|| Compact code base, less than 1k LOC with no external dependencies. |
3131
| 🎯 | Easy to use and extensible APIs set. |
3232
| 🧬 | It uses standard UIKit components at its core. No magic, just a combination of `UIScrollView`+`UIStackView`. |
@@ -42,6 +42,7 @@ You can think of it as `UITableView` but with several differences:
4242
- [Removing / Replacing Rows](#removingreplacingrows)
4343
- [Move Rows](#moverows)
4444
- [Hide / Show Rows](#hideshowrows)
45+
- [Hide / Show Rows with custom animations](#customanimations)
4546
- [Reload Rows](#reloadrows)
4647
- [Sizing Rows](#sizingrows)
4748
- [Fixed Row Size](#fixedrowsize)
@@ -232,6 +233,63 @@ Keep in mind: when you hide a rows the row still part of the stack and it's not
232233

233234
[↑ Back To Top](#index)
234235

236+
<a name="customanimations"/>
237+
238+
### Hide / Show Rows with custom animations
239+
240+
You can easily show or hide rows with any custom transition; your view controller just need to be conform to the `ScrollStackRowAnimatable` protocol.
241+
This protocol defines a set of animation infos (duration, delay, spring etc.) and two events you can override to perform actions:
242+
243+
```swift
244+
public protocol ScrollStackRowAnimatable {
245+
/// Animation main info.
246+
var animationInfo: ScrollStackAnimationInfo { get }
247+
248+
/// Animation will start to hide or show the row.
249+
func willBeginAnimationTransition(toHide: Bool)
250+
251+
/// Animation to hide/show the row did end.
252+
func didEndAnimationTransition(toHide: Bool)
253+
254+
/// Animation transition.
255+
func animateTransition(toHide: Bool)
256+
}
257+
```
258+
259+
So for example you can replicate the following animation:
260+
261+
![](./Resources/custom_transition.gif)
262+
263+
by using the following code:
264+
265+
```swift
266+
extension WelcomeVC: ScrollStackRowAnimatable {
267+
public var animationInfo: ScrollStackAnimationInfo {
268+
return ScrollStackAnimationInfo(duration: 1, delay: 0, springDamping: 0.8)
269+
}
270+
271+
public func animateTransition(toHide: Bool) {
272+
switch toHide {
273+
case true:
274+
self.view.transform = CGAffineTransform(translationX: -100, y: 0)
275+
self.view.alpha = 0
276+
277+
case false:
278+
self.view.transform = .identity
279+
self.view.alpha = 1
280+
}
281+
}
282+
283+
public func willBeginAnimationTransition(toHide: Bool) {
284+
if toHide == false {
285+
self.view.transform = CGAffineTransform(translationX: -100, y: 0)
286+
self.view.alpha = 0
287+
}
288+
}
289+
290+
}
291+
```
292+
235293
<a name="reloadrows"/>
236294

237295
### Reload Rows

Resources/custom_transition.gif

898 KB
Loading

ScrollStackController.xcodeproj/xcshareddata/xcschemes/ScrollStackController-tvOS.xcscheme

-100
This file was deleted.

ScrollStackController.xcodeproj/xcuserdata/daniele.xcuserdatad/xcschemes/xcschememanagement.plist

-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
<key>orderHint</key>
1010
<integer>0</integer>
1111
</dict>
12-
<key>ScrollStackController-tvOS.xcscheme_^#shared#^_</key>
13-
<dict>
14-
<key>orderHint</key>
15-
<integer>1</integer>
16-
</dict>
1712
<key>ScrollStackControllerDemo.xcscheme_^#shared#^_</key>
1813
<dict>
1914
<key>orderHint</key>

0 commit comments

Comments
 (0)