mirror of
https://github.com/makew0rld/amfora.git
synced 2024-12-04 14:46:29 -05:00
🚧 Scroll is applied correctly when navigating around
This commit is contained in:
parent
4b8982723f
commit
72f36afc9e
@ -104,8 +104,7 @@ func Init() {
|
||||
// Use for errors.
|
||||
reset := func() {
|
||||
bottomBar.SetLabel("")
|
||||
tabs[tab].applySelected()
|
||||
tabs[tab].applyBottomBar()
|
||||
tabs[tab].applyAll()
|
||||
App.SetFocus(tabs[tab].view)
|
||||
}
|
||||
|
||||
@ -454,8 +453,7 @@ func CloseTab() {
|
||||
tabRow.Highlight(strconv.Itoa(curTab)).ScrollToHighlight()
|
||||
|
||||
// Restore previous tab's state
|
||||
tabs[curTab].applySelected()
|
||||
tabs[curTab].applyBottomBar()
|
||||
tabs[curTab].applyAll()
|
||||
|
||||
App.SetFocus(tabs[curTab].view)
|
||||
|
||||
@ -486,8 +484,7 @@ func SwitchTab(tab int) {
|
||||
reformatPageAndSetView(tabs[curTab], tabs[curTab].page)
|
||||
tabPages.SwitchToPage(strconv.Itoa(curTab))
|
||||
tabRow.Highlight(strconv.Itoa(curTab)).ScrollToHighlight()
|
||||
tabs[curTab].applySelected()
|
||||
tabs[curTab].applyBottomBar()
|
||||
tabs[curTab].applyAll()
|
||||
|
||||
App.SetFocus(tabs[curTab].view)
|
||||
|
||||
@ -500,7 +497,7 @@ func Reload() {
|
||||
return
|
||||
}
|
||||
|
||||
cache.Remove(tabs[curTab].page.Url)
|
||||
go cache.Remove(tabs[curTab].page.Url)
|
||||
go func(t *tab) {
|
||||
handleURL(t, t.page.Url) // goURL is not used bc history shouldn't be added to
|
||||
if t == tabs[curTab] {
|
||||
|
@ -1,20 +1,18 @@
|
||||
package display
|
||||
|
||||
// applyHist is a history.go internal function, to load a URL in the history.
|
||||
func applyHist(t *tab) {
|
||||
handleURL(t, t.history.urls[t.history.pos]) // Load that position in history
|
||||
t.applyAll()
|
||||
}
|
||||
|
||||
func histForward(t *tab) {
|
||||
if t.history.pos >= len(t.history.urls)-1 {
|
||||
// Already on the most recent URL in the history
|
||||
return
|
||||
}
|
||||
t.history.pos++
|
||||
go func(tt *tab) {
|
||||
handleURL(tt, tt.history.urls[tt.history.pos]) // Load that position in history
|
||||
tt.applyScroll()
|
||||
tt.applySelected()
|
||||
if tt == tabs[curTab] {
|
||||
// Display the bottomBar state that handleURL set
|
||||
tt.applyBottomBar()
|
||||
}
|
||||
}(t)
|
||||
go applyHist(t)
|
||||
}
|
||||
|
||||
func histBack(t *tab) {
|
||||
@ -23,13 +21,5 @@ func histBack(t *tab) {
|
||||
return
|
||||
}
|
||||
t.history.pos--
|
||||
go func(tt *tab) {
|
||||
handleURL(tt, tt.history.urls[tt.history.pos]) // Load that position in history
|
||||
tt.applyScroll()
|
||||
tt.applySelected()
|
||||
if tt == tabs[curTab] {
|
||||
// Display the bottomBar state that handleURL set
|
||||
tt.applyBottomBar()
|
||||
}
|
||||
}(t)
|
||||
go applyHist(t)
|
||||
}
|
||||
|
@ -20,8 +20,9 @@ import (
|
||||
|
||||
// isValidTab indicates whether the passed tab is still being used, even if it's not currently displayed.
|
||||
func isValidTab(t *tab) bool {
|
||||
for i := range tabs {
|
||||
if tabs[i] == t {
|
||||
tempTabs := tabs
|
||||
for i := range tempTabs {
|
||||
if tempTabs[i] == t {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ func (t *tab) applySelected() {
|
||||
t.view.Highlight("")
|
||||
return
|
||||
} else if t.page.Mode == structs.ModeLinkSelect {
|
||||
t.view.Highlight(t.page.SelectedID).ScrollToHighlight()
|
||||
t.view.Highlight(t.page.SelectedID)
|
||||
|
||||
if t.mode == tabModeDone {
|
||||
// Page is not loading so bottomBar can change
|
||||
@ -218,3 +218,13 @@ func (t *tab) applySelected() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// applyAll uses applyScroll and applySelected to put a tab's TextView back the way it was.
|
||||
// It also uses applyBottomBar if this is the current tab.
|
||||
func (t *tab) applyAll() {
|
||||
t.applySelected()
|
||||
t.applyScroll()
|
||||
if t == tabs[curTab] {
|
||||
t.applyBottomBar()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user