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

Fixed weird animation in moveCurrentBarView when isInfinity is true #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

masatootake
Copy link

I guess it's just a mistake. The following code is using index, but it should be currentIndex.
https://github.com/EndouMari/TabPageViewController/blob/master/Sources/TabView.swift#L224

The below is the exact part.

    /**
     Make the tapped cell the current if isInfinity is true

     - parameter index: Next IndexPath√
     */
    fileprivate func updateCurrentIndexForTap(_ index: Int) {
        deselectVisibleCells()

        if isInfinity && (index < pageTabItemsCount) || (index >= pageTabItemsCount * 2) {
            currentIndex = (index < pageTabItemsCount) ? index + pageTabItemsCount : index - pageTabItemsCount
            shouldScrollToItem = true
        } else {
            currentIndex = index
        }
        let indexPath = IndexPath(item: index, section: 0) // FIX: index -> currentIndex
        moveCurrentBarView(indexPath, animated: true, shouldScroll: true)
    }

As a result of this mistake, when isInfinity is true, it causes a weird animation when moving tab from the range of pageTabItemsCount <= currentIndex < pageTabItemsCount * 2 to the range of currentIndex < pageTabItemsCount && pageTabItemsCount * 2 <= currentIndex.

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.

1 participant