fix ios tabs

Pull Request resolved: https://github.com/divkit/divkit-ios/pull/6
commit_hash:e043707fa17954429fcab6ddfd362a52afc70dbd
This commit is contained in:
nice77
2026-04-08 17:22:11 +03:00
committed by booster
parent 785d8b1e52
commit dddc5629f1
@@ -73,6 +73,8 @@ final class TabContentsView: BlockView {
private var scrolledPageIndex: CGFloat = 0
private var isAnimatingTransition = false
var visibleBoundsTrackingSubviews: [VisibleBoundsTrackingView] { collectionView.asArray() }
var effectiveBackgroundColor: UIColor? { backgroundView?.effectiveBackgroundColor }
@@ -199,7 +201,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()
}
}
@@ -232,6 +236,7 @@ final class TabContentsView: BlockView {
}
private func updateContentOffset() {
isAnimatingTransition = true
collectionView.setContentOffset(selectedPageContentOffset, animated: true)
}
@@ -271,6 +276,7 @@ extension TabContentsView: UICollectionViewDelegate {
func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
overscrollDelegate?.onDidEndScrollingAnimation(scrollView)
isAnimatingTransition = false
delegate?.tabContentsViewDidEndAnimation()
updateSelectedPageIndexFromRelativeContentOffset(isIntermediate: false)
}