Skip to content

Commit

Permalink
Merge pull request #311 from gabreho/gabreho/horizontal-scroll-actions
Browse files Browse the repository at this point in the history
Enable horizontal scroll actions.
  • Loading branch information
kyleve authored Aug 5, 2021
2 parents cefc357 + 436292f commit 0ac8306
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ListableUI/Sources/ListView/ListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ public final class ListView : UIView, KeyboardObserverDelegate
} else {
self.collectionView.scrollToItem(
at: toIndexPath,
at: position.position.UICollectionViewScrollPosition,
at: position.position.toUICollectionViewScrollPosition(for: self.collectionViewLayout.layout.direction),
animated: false
)
}
Expand Down
19 changes: 14 additions & 5 deletions ListableUI/Sources/ScrollPosition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,20 @@ extension ScrollPosition
/// Scroll the item to the bottom of the list.
case bottom

var UICollectionViewScrollPosition : UICollectionView.ScrollPosition {
switch self {
case .top: return .top
case .centered: return .centeredVertically
case .bottom: return .bottom
func toUICollectionViewScrollPosition(for direction : LayoutDirection) -> UICollectionView.ScrollPosition {
switch direction {
case .vertical:
switch self {
case .top: return .top
case .centered: return .centeredVertically
case .bottom: return .bottom
}
case .horizontal:
switch self {
case .top: return .left
case .centered: return .centeredHorizontally
case .bottom: return .right
}
}
}
}
Expand Down

0 comments on commit 0ac8306

Please sign in to comment.