diff --git a/Sources/FSPagerView.swift b/Sources/FSPagerView.swift index 1492e23..7ee1e49 100644 --- a/Sources/FSPagerView.swift +++ b/Sources/FSPagerView.swift @@ -221,7 +221,6 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega internal weak var collectionViewLayout: FSPagerViewLayout! internal weak var collectionView: FSPagerCollectionView! internal weak var contentView: UIView! - internal var timer: Timer? internal var numberOfItems: Int = 0 internal var numberOfSections: Int = 0 @@ -253,10 +252,15 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega } return IndexPath(item: 0, section: 0) } - + fileprivate var isPossiblyRotating: Bool { + guard let animationKeys = self.contentView.layer.animationKeys() else { + return false + } + let rotationAnimationKeys = ["position", "bounds.origin", "bounds.size"] + return animationKeys.contains(where: { rotationAnimationKeys.contains($0) }) + } fileprivate var possibleTargetingIndexPath: IndexPath? - // MARK: - Overriden functions public override init(frame: CGRect) { @@ -387,7 +391,7 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega } public func scrollViewDidScroll(_ scrollView: UIScrollView) { - if self.numberOfItems > 0 { + if !self.isPossiblyRotating && self.numberOfItems > 0 { // In case someone is using KVO let currentIndex = lround(Double(self.scrollOffset)) % self.numberOfItems if (currentIndex != self.currentIndex) {