-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vertical scrolling support #1
base: master
Are you sure you want to change the base?
Vertical scrolling support #1
Conversation
I just learned to code with Mimo and I'd appreciate any pointers on improving my code ❤️😄 |
switch scrollDirection { | ||
case .horizontal: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of chaining 2 switch
statements inside another switch
, you can do it like this:
switch scrollDirection { | |
case .horizontal: | |
switch (scrollDirection, snapPosition) { | |
case (.horizontal, .left): | |
case (.horizontal, .center): | |
case (.horizontal, .right): | |
case (.vertical, .center): | |
case (.vertical, .top): | |
case (.vertical, .bottom): | |
case (.horizontal, .top), (.horizontal, .bottom), (.vertical, .left), (.vertical, .right): |
switch scrollDirection { | ||
case .horizontal: | ||
let itemHorizontalPosition: CGFloat | ||
|
||
switch snapPosition { | ||
case .left: | ||
itemHorizontalPosition = layoutAttributes.frame.minX - collectionView.contentInset.left | ||
case .center: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
The logic for horizontal scrolling moved inside switch statements for
scrollDirection
.I added three cases for
.vertical
scrolling:.top
.center
.bottom
The cells of a collectionView snap to the top, center, or bottom when the
scrollDirection
is set tovertical
.