Skip to content
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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Lcarvajal-zz
Copy link

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 to vertical.

@Lcarvajal-zz
Copy link
Author

Lcarvajal-zz commented May 12, 2021

I just learned to code with Mimo and I'd appreciate any pointers on improving my code ❤️😄

Comment on lines +38 to +39
switch scrollDirection {
case .horizontal:
Copy link
Collaborator

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:

Suggested change
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):

Comment on lines +75 to +82
switch scrollDirection {
case .horizontal:
let itemHorizontalPosition: CGFloat

switch snapPosition {
case .left:
itemHorizontalPosition = layoutAttributes.frame.minX - collectionView.contentInset.left
case .center:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants