Skip to content

Commit

Permalink
center the target tab
Browse files Browse the repository at this point in the history
  • Loading branch information
brindy committed Apr 23, 2024
1 parent b3b110e commit 27e6885
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions DuckDuckGo/WebViewTransition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,17 @@ class FromWebViewTransition: WebViewTransition {

guard let webView = mainViewController.currentTab?.webView,
let tab = mainViewController.tabManager.model.currentTab,
let rowIndex = tabSwitcherViewController.tabsModel.indexOf(tab: tab),
let layoutAttr = tabSwitcherViewController.collectionView.layoutAttributesForItem(at: IndexPath(row: rowIndex, section: 0)),
let rowIndex = tabSwitcherViewController.tabsModel.indexOf(tab: tab)
else {
tabSwitcherViewController.view.alpha = 1
transitionContext.completeTransition(true)
return
}

let indexPath = IndexPath(row: rowIndex, section: 0)
tabSwitcherViewController.collectionView.scrollToItem(at: indexPath, at: .centeredVertically, animated: false)

guard let layoutAttr = tabSwitcherViewController.collectionView.layoutAttributesForItem(at: indexPath),
let preview = tabSwitcherViewController.previewsSource.preview(for: tab)
else {
tabSwitcherViewController.view.alpha = 1
Expand Down

0 comments on commit 27e6885

Please sign in to comment.