From dddc5629f1954efc3f39d8346bbfe5bd015a3632 Mon Sep 17 00:00:00 2001 From: nice77 Date: Wed, 8 Apr 2026 17:14:55 +0300 Subject: [PATCH] fix ios tabs Pull Request resolved: https://github.com/divkit/divkit-ios/pull/6 commit_hash:e043707fa17954429fcab6ddfd362a52afc70dbd --- .../LayoutKit/UI/Views/TabbedPages/TabContentsView.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/ios/LayoutKit/LayoutKit/UI/Views/TabbedPages/TabContentsView.swift b/client/ios/LayoutKit/LayoutKit/UI/Views/TabbedPages/TabContentsView.swift index 03dd92876..4523d57d3 100644 --- a/client/ios/LayoutKit/LayoutKit/UI/Views/TabbedPages/TabContentsView.swift +++ b/client/ios/LayoutKit/LayoutKit/UI/Views/TabbedPages/TabContentsView.swift @@ -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) }