Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions LayoutKit/LayoutKit/UI/Views/TabbedPages/TabContentsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ final class TabContentsView: BlockView {
private var selectedPageContentOffset: CGPoint {
CGPoint(x: collectionView.bounds.width * selectedPageIndex, y: 0)
}
private var isAnimatingTransition = false

init() {
collectionView = VisibleBoundsTrackingCollectionView(
Expand Down Expand Up @@ -199,7 +200,9 @@ final class TabContentsView: BlockView {
collectionView.isScrollEnabled = model.scrollingEnabled

if oldModel != model || layout == nil || state.selectedPageIndex != selectedPageIndex {
updateSelectedPageIndexIfNeeded(state.selectedPageIndex)
if !isAnimatingTransition {
updateSelectedPageIndexIfNeeded(state.selectedPageIndex)
}
setNeedsLayout()
}
}
Expand All @@ -215,6 +218,7 @@ final class TabContentsView: BlockView {
return
}

isAnimatingTransition = true
selectedPageIndex = idx
updateContentOffset()
}
Expand All @@ -226,7 +230,8 @@ final class TabContentsView: BlockView {
model: blocks[indexPath.row],
observer: observer,
overscrollDelegate: overscrollDelegate,
renderingDelegate: renderingDelegate
renderingDelegate: renderingDelegate,
accessibilityElement: blocks[indexPath.row].accessibilityElement
)
}
}
Expand Down Expand Up @@ -271,6 +276,7 @@ extension TabContentsView: UICollectionViewDelegate {

func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
overscrollDelegate?.onDidEndScrollingAnimation(scrollView)
isAnimatingTransition = false
delegate?.tabContentsViewDidEndAnimation()
updateSelectedPageIndexFromRelativeContentOffset(isIntermediate: false)
}
Expand Down