TabView: Better animations for closing tabs in the middle
This commit is contained in:
@@ -156,9 +156,13 @@ class TabBarView: UIView
|
|||||||
} else {
|
} else {
|
||||||
let newTabView = makeTabView(withIdentifier: identifier)
|
let newTabView = makeTabView(withIdentifier: identifier)
|
||||||
if animated { newTabView.collapsed = true }
|
if animated { newTabView.collapsed = true }
|
||||||
|
if i < tabViews.count {
|
||||||
|
tabViews.insert(newTabView, at: i - 1)
|
||||||
|
} else {
|
||||||
tabViews.append(newTabView)
|
tabViews.append(newTabView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
layoutSubviews()
|
layoutSubviews()
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,11 @@ class TabController
|
|||||||
|
|
||||||
func createNewTab(url: URL?, webViewConfiguration: WKWebViewConfiguration?) -> Tab {
|
func createNewTab(url: URL?, webViewConfiguration: WKWebViewConfiguration?) -> Tab {
|
||||||
let tab = Tab(url: url, policyManager: policyManager, webViewConfiguration: webViewConfiguration)
|
let tab = Tab(url: url, policyManager: policyManager, webViewConfiguration: webViewConfiguration)
|
||||||
|
if tabs.count > 0 {
|
||||||
|
tabs.insert(tab, at: activeTabIndex + 1)
|
||||||
|
} else {
|
||||||
tabs.append(tab)
|
tabs.append(tab)
|
||||||
|
}
|
||||||
|
|
||||||
return tab
|
return tab
|
||||||
}
|
}
|
||||||
@@ -43,7 +47,9 @@ class TabController
|
|||||||
tabs.remove(at: index)
|
tabs.remove(at: index)
|
||||||
|
|
||||||
if tabs.count > 0 {
|
if tabs.count > 0 {
|
||||||
if index < tabs.count {
|
if (index - 1) >= 0 {
|
||||||
|
activeTabIndex = index - 1
|
||||||
|
} else if index < tabs.count {
|
||||||
activeTabIndex = index
|
activeTabIndex = index
|
||||||
} else {
|
} else {
|
||||||
activeTabIndex = tabs.count - 1
|
activeTabIndex = tabs.count - 1
|
||||||
|
|||||||
Reference in New Issue
Block a user