diff --git a/containerbox.go b/containerbox.go index 5a9899d..96c27b4 100644 --- a/containerbox.go +++ b/containerbox.go @@ -274,7 +274,7 @@ func (this *containerBox) doLayout () { // offset the content bounds by the scroll so children can be positioned // accordingly. this.constrainScroll() - this.contentBounds = this.contentBounds.Sub(this.scroll).Sub(innerBounds.Min) + this.contentBounds = this.contentBounds.Add(this.scroll).Sub(innerBounds.Min) // arrange children if this.layout != nil { @@ -294,19 +294,19 @@ func (this *containerBox) constrainScroll () { // X if width <= innerBounds.Dx() { this.scroll.X = 0 - } else if this.scroll.X < 0 { + } else if this.scroll.X > 0 { this.scroll.X = 0 - } else if this.scroll.X > width - innerBounds.Dx() { - this.scroll.X = width - innerBounds.Dx() + } else if this.scroll.X < innerBounds.Dx() - width { + this.scroll.X = innerBounds.Dx() - width } // Y if height <= innerBounds.Dy() { this.scroll.Y = 0 - } else if this.scroll.Y < 0 { + } else if this.scroll.Y > 0 { this.scroll.Y = 0 - } else if this.scroll.Y > height - innerBounds.Dy() { - this.scroll.Y = height - innerBounds.Dy() + } else if this.scroll.Y < innerBounds.Dy() - height { + this.scroll.Y = innerBounds.Dy() - height } }