TabView: Better animations for closing tabs in the middle

This commit is contained in:
James Magahern
2021-02-15 19:09:20 -08:00
parent 6eb320bf7a
commit d62fa42f57
2 changed files with 13 additions and 3 deletions

View File

@@ -33,7 +33,11 @@ class TabController
func createNewTab(url: URL?, webViewConfiguration: WKWebViewConfiguration?) -> Tab {
let tab = Tab(url: url, policyManager: policyManager, webViewConfiguration: webViewConfiguration)
tabs.append(tab)
if tabs.count > 0 {
tabs.insert(tab, at: activeTabIndex + 1)
} else {
tabs.append(tab)
}
return tab
}
@@ -43,7 +47,9 @@ class TabController
tabs.remove(at: index)
if tabs.count > 0 {
if index < tabs.count {
if (index - 1) >= 0 {
activeTabIndex = index - 1
} else if index < tabs.count {
activeTabIndex = index
} else {
activeTabIndex = tabs.count - 1