From 9d234761210698c6767289b02ca1dc642e0290d3 Mon Sep 17 00:00:00 2001 From: Tomas Strba Date: Wed, 17 Nov 2021 10:50:40 +0100 Subject: [PATCH] Closing animation duration changed to 0.15 --- .../TabBar/View/TabBarViewController.swift | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/DuckDuckGo/TabBar/View/TabBarViewController.swift b/DuckDuckGo/TabBar/View/TabBarViewController.swift index a822baa64c..9dc1d7a93a 100644 --- a/DuckDuckGo/TabBar/View/TabBarViewController.swift +++ b/DuckDuckGo/TabBar/View/TabBarViewController.swift @@ -398,30 +398,34 @@ extension TabBarViewController: TabCollectionViewModelDelegate { let shouldScroll = collectionView.isAtEndScrollPosition && (!self.view.isMouseLocationInsideBounds() || removedIndex == self.collectionView.numberOfItems(inSection: 0) - 1) let visiRect = collectionView.enclosingScrollView!.contentView.documentVisibleRect - collectionView.animator().performBatchUpdates { - let tabWidth = currentTabWidth(removedIndex: removedIndex) - if shouldScroll { - collectionView.animator().scroll(CGPoint(x: scrollView.contentView.bounds.origin.x - tabWidth, y: 0)) - } + NSAnimationContext.runAnimationGroup { context in + context.duration = 0.15 - if collectionView.selectionIndexPaths != selectionIndexPathSet { - collectionView.clearSelection() - collectionView.animator().selectItems(at: selectionIndexPathSet, scrollPosition: .centeredHorizontally) - } - collectionView.animator().deleteItems(at: removedIndexPathSet) - } completionHandler: { [weak self] _ in - guard let self = self else { return } + collectionView.animator().performBatchUpdates { + let tabWidth = currentTabWidth(removedIndex: removedIndex) + if shouldScroll { + collectionView.animator().scroll(CGPoint(x: scrollView.contentView.bounds.origin.x - tabWidth, y: 0)) + } - self.frozenLayout = self.view.isMouseLocationInsideBounds() - if !self.frozenLayout { - self.updateLayout() - } - self.updateEmptyTabArea() - self.enableScrollButtons() - self.hideTooltip() + if collectionView.selectionIndexPaths != selectionIndexPathSet { + collectionView.clearSelection() + collectionView.animator().selectItems(at: selectionIndexPathSet, scrollPosition: .centeredHorizontally) + } + collectionView.animator().deleteItems(at: removedIndexPathSet) + } completionHandler: { [weak self] _ in + guard let self = self else { return } - if !shouldScroll { - self.collectionView.enclosingScrollView!.contentView.scroll(to: visiRect.origin) + self.frozenLayout = self.view.isMouseLocationInsideBounds() + if !self.frozenLayout { + self.updateLayout() + } + self.updateEmptyTabArea() + self.enableScrollButtons() + self.hideTooltip() + + if !shouldScroll { + self.collectionView.enclosingScrollView!.contentView.scroll(to: visiRect.origin) + } } } }