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

Fix regression causing menuInteraction property not to work properly #486

Merged

Conversation

hugehoge
Copy link
Contributor

Close #485

The behavior of menuInteraction = .swipe // or .none requires collectionView.isScrollEnabled = false.

But the menuInteraction changes call the configureMenuInteraction() directly and pass through the collectionView.isScrollEnabled = false setting.

/// Determine how users can interact with the menu items.
/// _Default: .scrolling_
public var menuInteraction: PagingMenuInteraction {
get { return options.menuInteraction }
set { options.menuInteraction = newValue }
}

var options: PagingOptions {
didSet {
optionsChanged(oldValue: oldValue)
}
}

private func optionsChanged(oldValue: PagingOptions) {
if options.menuInteraction != oldValue.menuInteraction {
configureMenuInteraction()
}

private func configureCollectionView() {
collectionView.isScrollEnabled = false
collectionView.alwaysBounceHorizontal = false
collectionView.showsHorizontalScrollIndicator = false
collectionView.dataSource = self
if #available(iOS 11.0, *) {
collectionView.contentInsetAdjustmentBehavior = .never
}
configureMenuInteraction()
}
private func configureMenuInteraction() {
if let swipeGestureRecognizerLeft = swipeGestureRecognizerLeft {
collectionView.removeGestureRecognizer(swipeGestureRecognizerLeft)
}
if let swipeGestureRecognizerRight = swipeGestureRecognizerRight {
collectionView.removeGestureRecognizer(swipeGestureRecognizerRight)
}
switch (options.menuInteraction) {
case .scrolling:
collectionView.isScrollEnabled = true
collectionView.alwaysBounceHorizontal = true
case .swipe:
setupGestureRecognizers()
case .none:
break
}
}

I move the collectionView's setting codes and add a swipe animation based on ver1.7.0 implements.

private func configureMenuInteraction() {
collectionView.isScrollEnabled = false
collectionView.alwaysBounceHorizontal = false
if let swipeGestureRecognizerLeft = swipeGestureRecognizerLeft {
collectionView.removeGestureRecognizer(swipeGestureRecognizerLeft)
}
if let swipeGestureRecognizerRight = swipeGestureRecognizerRight {
collectionView.removeGestureRecognizer(swipeGestureRecognizerRight)
}
switch (options.menuInteraction) {
case .scrolling:
collectionView.isScrollEnabled = true
collectionView.alwaysBounceHorizontal = true
case .swipe:
setupGestureRecognizers()
case .none:
break
}
}

select(pagingItem: item, animated: true)

The menuInteraction property hadn't worked properly since ver 2.0.0.
So, pick the ver 1.7.0 implements and restored.
@rechsteiner
Copy link
Owner

Thank you for fixing this 🙌

@rechsteiner rechsteiner merged commit 35d0439 into rechsteiner:master May 5, 2020
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.

menuInteraction property may not work properly
2 participants