Fix scroll behavior for ContainerBox
This commit is contained in:
parent
664ce5f556
commit
96fa7b5623
@ -274,7 +274,7 @@ func (this *containerBox) doLayout () {
|
|||||||
// offset the content bounds by the scroll so children can be positioned
|
// offset the content bounds by the scroll so children can be positioned
|
||||||
// accordingly.
|
// accordingly.
|
||||||
this.constrainScroll()
|
this.constrainScroll()
|
||||||
this.contentBounds = this.contentBounds.Sub(this.scroll).Sub(innerBounds.Min)
|
this.contentBounds = this.contentBounds.Add(this.scroll).Sub(innerBounds.Min)
|
||||||
|
|
||||||
// arrange children
|
// arrange children
|
||||||
if this.layout != nil {
|
if this.layout != nil {
|
||||||
@ -294,19 +294,19 @@ func (this *containerBox) constrainScroll () {
|
|||||||
// X
|
// X
|
||||||
if width <= innerBounds.Dx() {
|
if width <= innerBounds.Dx() {
|
||||||
this.scroll.X = 0
|
this.scroll.X = 0
|
||||||
} else if this.scroll.X < 0 {
|
} else if this.scroll.X > 0 {
|
||||||
this.scroll.X = 0
|
this.scroll.X = 0
|
||||||
} else if this.scroll.X > width - innerBounds.Dx() {
|
} else if this.scroll.X < innerBounds.Dx() - width {
|
||||||
this.scroll.X = width - innerBounds.Dx()
|
this.scroll.X = innerBounds.Dx() - width
|
||||||
}
|
}
|
||||||
|
|
||||||
// Y
|
// Y
|
||||||
if height <= innerBounds.Dy() {
|
if height <= innerBounds.Dy() {
|
||||||
this.scroll.Y = 0
|
this.scroll.Y = 0
|
||||||
} else if this.scroll.Y < 0 {
|
} else if this.scroll.Y > 0 {
|
||||||
this.scroll.Y = 0
|
this.scroll.Y = 0
|
||||||
} else if this.scroll.Y > height - innerBounds.Dy() {
|
} else if this.scroll.Y < innerBounds.Dy() - height {
|
||||||
this.scroll.Y = height - innerBounds.Dy()
|
this.scroll.Y = innerBounds.Dy() - height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user