Fix browser page scrolling by initializing EntryHeight and correcting scroll handler type assertion

This commit is contained in:
gmp
2026-06-01 10:57:34 -04:00
parent 281298ac1f
commit 6709f52e0f
17 changed files with 855 additions and 155 deletions
+8 -5
View File
@@ -100,6 +100,7 @@ func (s *State) layout() []ui.Element {
dpW := ui.ToDp(ui.Px(s.PixelWidth), s.scale)
dpH := ui.ToDp(ui.Px(s.PixelHeight), s.scale)
// Calculate VisibleCount before laying out the browser page.
// This ensures the browser shows entries based on the current viewport.
if s.PixelHeight > 0 && s.scale > 0 {
@@ -139,11 +140,11 @@ func HandleScroll(data any) {
}
}
// HandleBrowserScroll updates the browser scroll index by the given delta.
// Delegates to the browser package's handler.
// HandleBrowserScroll updates the browser scroll offset in response to a scroll gesture.
// The delta is in pixels (from gesture.Scroll.Update). Delegates to the browser package.
func HandleBrowserScroll(data any) {
delta := data.(int) // entries
browser.HandleScroll(&TheState.Browser, delta)
delta := data.(int) // pixel delta from gesture.Scroll.Update
browser.HandlePixelScroll(&TheState.Browser, delta)
}
// GoToBrowser switches the app to the browser page.
@@ -168,11 +169,13 @@ func ToggleSortOrder(data any) {
// Cycle through the 4 sort modes
TheState.Browser.SortMode = (TheState.Browser.SortMode + 1) % 4
// Reset scroll on sort change
TheState.Browser.ScrollIndex = 0
TheState.Browser.ScrollOffset = 0
// Clear cached pages so they reload with the new sort order
TheState.Browser.Pages = make(map[int]*browser.Page)
// Reload initial pages with the new sort order
browser.LoadInitialPages(&TheState.Browser)
// Recompute search results if there's an active search query
browser.HandleSortModeChange(&TheState.Browser)
}
// EditorLayout computes the element tree for the editor page.