fix(scroll): make auto-scroll on page change work consistently

This commit is contained in:
Piotr Grabowski 2024-08-10 12:52:49 +02:00
parent 2970fabeb1
commit 9262f1bc59

View file

@ -95,6 +95,7 @@ func (app *App) scroll(dx, dy float64) {
} }
func (app *App) scrollToStart() { func (app *App) scrollToStart() {
app.W.ScrolledWindow.SetVAdjustment(nil) // Needed to prevent a bug where it scrolls back by itself
app.W.ScrolledWindow.GetVAdjustment().SetValue(0) // Vertical: top app.W.ScrolledWindow.GetVAdjustment().SetValue(0) // Vertical: top
var newHadj float64 = 0 var newHadj float64 = 0
@ -102,18 +103,21 @@ func (app *App) scrollToStart() {
imgw, _ := app.getImageAreaInnerSize() imgw, _ := app.getImageAreaInnerSize()
newHadj = float64(imgw) newHadj = float64(imgw)
} }
app.W.ScrolledWindow.SetHAdjustment(nil)
app.W.ScrolledWindow.GetHAdjustment().SetValue(newHadj) // Horizontal: left (non-manga) or right (manga) edge app.W.ScrolledWindow.GetHAdjustment().SetValue(newHadj) // Horizontal: left (non-manga) or right (manga) edge
} }
func (app *App) scrollToEnd() { func (app *App) scrollToEnd() {
imgw, imgh := app.getImageAreaInnerSize() imgw, imgh := app.getImageAreaInnerSize()
app.W.ScrolledWindow.SetVAdjustment(nil)
app.W.ScrolledWindow.GetVAdjustment().SetValue(float64(imgh)) // Vertical: bottom app.W.ScrolledWindow.GetVAdjustment().SetValue(float64(imgh)) // Vertical: bottom
var newHadj float64 = 0 var newHadj float64 = 0
if !app.Config.MangaMode { if !app.Config.MangaMode {
newHadj = float64(imgw) newHadj = float64(imgw)
} }
app.W.ScrolledWindow.SetHAdjustment(nil)
app.W.ScrolledWindow.GetHAdjustment().SetValue(newHadj) // Horizontal: left (manga) or right (non-manga) edge app.W.ScrolledWindow.GetHAdjustment().SetValue(newHadj) // Horizontal: left (manga) or right (non-manga) edge
} }