Skip to content

Commit

Permalink
Fix crash PagingController.collectionView.selectItem
Browse files Browse the repository at this point in the history
  • Loading branch information
olegKa committed Apr 25, 2024
1 parent 6e955f1 commit 6bed998
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions Parchment/Classes/PagingController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,15 @@ final class PagingController: NSObject {
animated: false
)

collectionView.selectItem(
at: visibleItems.indexPath(for: pagingItem),
animated: false,
scrollPosition: options.scrollPosition
)

DispatchQueue.main.async { [weak self] in
guard let self, let indexPath = self.visibleItems.indexPath(for: pagingItem) else { return }
self.collectionView.selectItem(
at: indexPath,
animated: false,
scrollPosition: self.options.scrollPosition
)
}

default:
break
}
Expand Down
2 changes: 1 addition & 1 deletion Parchment/Classes/PagingOptions.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import UIKit

public struct PagingOptions {
public struct PagingOptions: @unchecked Sendable {
/// The size for each of the menu items. _Default:
/// .sizeToFit(minWidth: 150, height: 40)_
public var menuItemSize: PagingMenuItemSize
Expand Down

0 comments on commit 6bed998

Please sign in to comment.