diff --git a/views/view_scroll.go b/views/view_scroll.go index 77dd8fe..857f122 100644 --- a/views/view_scroll.go +++ b/views/view_scroll.go @@ -55,6 +55,13 @@ func (v *ScrollView) Draw(buf *tui.ViewBuffer) { copyBufferHeight = v.buf.Height() } + // copy buffer + for x := 0; x < copyBufferWidth; x++ { + for y := 0; y < copyBufferHeight; y++ { + buf.Set(x, y, v.buf.Get(v.horizontalScrollOffset+x, v.verticalScrollOffset+y)) + } + } + scrollVHeight := int(float64(buf.Height()) / float64(v.buf.Height()) * float64(v.height)) scrollVStart := int(math.Ceil(float64(v.verticalScrollOffset) / float64(v.buf.Height()) * float64(v.height))) @@ -75,13 +82,6 @@ func (v *ScrollView) Draw(buf *tui.ViewBuffer) { } } - // copy buffer - for x := 0; x < copyBufferWidth; x++ { - for y := 0; y < copyBufferHeight; y++ { - buf.Set(x, y, v.buf.Get(v.horizontalScrollOffset+x, v.verticalScrollOffset+y)) - } - } - // vertical scrollbar if scrollV { for y := 0; y < v.height; y++ {