@@ -26,7 +26,7 @@ You can think of it as `UITableView` but with several differences:
26
26
| --- | --------------------------------------------------------------------------------- |
27
27
| 🕺 | Create complex layout without the boilerplate required by view recyling of ` UICollectionView ` or ` UITableView ` . |
28
28
| 🧩 | 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 ! |
30
30
| ⏱ | Compact code base, less than 1k LOC with no external dependencies. |
31
31
| 🎯 | Easy to use and extensible APIs set. |
32
32
| 🧬 | 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:
42
42
- [Removing / Replacing Rows](#removingreplacingrows)
43
43
- [Move Rows](#moverows)
44
44
- [Hide / Show Rows](#hideshowrows)
45
+ - [Hide / Show Rows with custom animations](#customanimations)
45
46
- [Reload Rows](#reloadrows)
46
47
- [Sizing Rows](#sizingrows)
47
48
- [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
232
233
233
234
[ ↑ Back To Top] ( #index )
234
235
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
+
235
293
<a name =" reloadrows " />
236
294
237
295
### Reload Rows
0 commit comments