Skip to content

Commit 8ada87d

Browse files
authored
Merge pull request #32 from NicFontana/feat/scrollview-delegate-method
Feat: Add `scrollStackDidEndScrollingAnimation(_ stackView: ScrollStack)` delegate method
2 parents be6fe36 + b47668b commit 8ada87d

File tree

3 files changed

+40
-23
lines changed

3 files changed

+40
-23
lines changed

README.md

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -634,33 +634,37 @@ Example:
634634

635635
```swift
636636
class ViewController: ScrollStackController, ScrollStackControllerDelegate {
637-
638-
func viewDidLoad() {
639-
super.viewDidLoad()
640-
641-
self.scrollStack.stackDelegate = self
642-
}
643-
644-
func scrollStackDidScroll(_ stackView: ScrollStack, offset: CGPoint) {
645-
// stack did scroll
646-
}
647-
648-
func scrollStackRowDidBecomeVisible(_ stackView: ScrollStack, row: ScrollStackRow, index: Int, state: ScrollStack.RowVisibility) {
649-
// Row did become partially or entirely visible.
650-
}
637+
638+
func viewDidLoad() {
639+
super.viewDidLoad()
640+
641+
self.scrollStack.stackDelegate = self
642+
}
643+
644+
func scrollStackDidScroll(_ stackView: ScrollStack, offset: CGPoint) {
645+
// Stack did scroll
646+
}
651647

652-
func scrollStackRowDidBecomeHidden(_ stackView: ScrollStack, row: ScrollStackRow, index: Int, state: ScrollStack.RowVisibility) {
653-
// Row did become partially or entirely invisible.
654-
}
648+
649+
func scrollStackDidEndScrollingAnimation(_ stackView: ScrollStack) {
650+
// Scrolling animation has ended
651+
}
655652

656-
func scrollStackDidUpdateLayout(_ stackView: ScrollStack) {
657-
// This function is called when layout is updated (added, removed, hide or show one or more rows).
658-
}
653+
func scrollStackRowDidBecomeVisible(_ stackView: ScrollStack, row: ScrollStackRow, index: Int, state: ScrollStack.RowVisibility) {
654+
// Row did become partially or entirely visible.
655+
}
659656

660-
func scrollStackContentSizeDidChange(_ stackView: ScrollStack, from oldValue: CGSize, to newValue: CGSize) {
661-
// This function is called when content size of the stack did change (remove/add, hide/show rows).
662-
}
657+
func scrollStackRowDidBecomeHidden(_ stackView: ScrollStack, row: ScrollStackRow, index: Int, state: ScrollStack.RowVisibility) {
658+
// Row did become partially or entirely invisible.
659+
}
663660

661+
func scrollStackDidUpdateLayout(_ stackView: ScrollStack) {
662+
// This function is called when layout is updated (added, removed, hide or show one or more rows).
663+
}
664+
665+
func scrollStackContentSizeDidChange(_ stackView: ScrollStack, from oldValue: CGSize, to newValue: CGSize) {
666+
// This function is called when content size of the stack did change (remove/add, hide/show rows).
667+
}
664668
}
665669
```
666670

Sources/ScrollStackController/ScrollStack.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,14 @@ open class ScrollStack: UIScrollView, UIScrollViewDelegate {
10911091
dispatchRowsVisibilityChangesTo(stackDelegate)
10921092
}
10931093

1094+
public func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
1095+
guard let stackDelegate = stackDelegate else {
1096+
return
1097+
}
1098+
1099+
stackDelegate.scrollStackDidEndScrollingAnimation(self)
1100+
}
1101+
10941102
open override func layoutSubviews() {
10951103
super.layoutSubviews()
10961104

Sources/ScrollStackController/Support/ScrollStack+Protocols.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ public protocol ScrollStackControllerDelegate: AnyObject {
6868
/// - Parameter offset: current scroll offset.
6969
func scrollStackDidScroll(_ stackView: ScrollStack, offset: CGPoint)
7070

71+
/// Tells the delegate when a scrolling animation in the scroll view concludes.
72+
///
73+
/// - Parameter stackView: The ScrollStack object that’s performing the scrolling animation.
74+
func scrollStackDidEndScrollingAnimation(_ stackView: ScrollStack)
75+
7176
/// Row did become partially or entirely visible.
7277
///
7378
/// - Parameter row: target row.

0 commit comments

Comments
 (0)