From 0a05007c4e1c8ac7a4a4d9d8b40e9fca0b31e0e8 Mon Sep 17 00:00:00 2001 From: Bradley Cicenas Date: Fri, 7 Jul 2017 12:38:02 +0000 Subject: [PATCH] skip offset updates in page scroll if no pages --- cursor.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cursor.go b/cursor.go index 0f87905..34ccc39 100644 --- a/cursor.go +++ b/cursor.go @@ -143,8 +143,10 @@ func (gc *GridCursor) PgUp() { } nextidx := int(math.Max(0.0, float64(idx-cGrid.MaxRows()))) - cGrid.Offset = int(math.Max(float64(cGrid.Offset-cGrid.MaxRows()), - float64(0))) + if gc.pgCount() > 0 { + cGrid.Offset = int(math.Max(float64(cGrid.Offset-cGrid.MaxRows()), + float64(0))) + } active := gc.filtered[idx] next := gc.filtered[nextidx] @@ -163,10 +165,11 @@ func (gc *GridCursor) PgDown() { return } - nextidx := int(math.Min(float64(gc.Len()-1), - float64(idx+cGrid.MaxRows()))) - cGrid.Offset = int(math.Min(float64(cGrid.Offset+cGrid.MaxRows()), - float64(gc.Len()-cGrid.MaxRows()))) + nextidx := int(math.Min(float64(gc.Len()-1), float64(idx+cGrid.MaxRows()))) + if gc.pgCount() > 0 { + cGrid.Offset = int(math.Min(float64(cGrid.Offset+cGrid.MaxRows()), + float64(gc.Len()-cGrid.MaxRows()))) + } active := gc.filtered[idx] next := gc.filtered[nextidx]