mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 18:35:34 +00:00
layout: improve documentation for List.ScrollTo and List.ScrollBy
Signed-off-by: Dominik Honnef <dominik@honnef.co>
This commit is contained in:
committed by
Elias Naur
parent
dc9a4a4009
commit
107401cf07
+6
-4
@@ -356,8 +356,11 @@ func (l *List) layout(ops *op.Ops, macro op.MacroOp) Dimensions {
|
|||||||
return Dimensions{Size: dims}
|
return Dimensions{Size: dims}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScrollBy scrolls the list by a relative amount of items. The result will only be accurate if all items have the same
|
// ScrollBy scrolls the list by a relative amount of items.
|
||||||
// height. Otherwise, it will be approximate.
|
//
|
||||||
|
// Fractional scrolling may be inaccurate for items of differing
|
||||||
|
// dimensions. This includes scrolling by integer amounts if the current
|
||||||
|
// l.Position.Offset is non-zero.
|
||||||
func (l *List) ScrollBy(num float32) {
|
func (l *List) ScrollBy(num float32) {
|
||||||
// Split number of items into integer and fractional parts
|
// Split number of items into integer and fractional parts
|
||||||
i, f := math.Modf(float64(num))
|
i, f := math.Modf(float64(num))
|
||||||
@@ -378,8 +381,7 @@ func (l *List) ScrollBy(num float32) {
|
|||||||
l.Position.BeforeEnd = true
|
l.Position.BeforeEnd = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScrollTo scrolls to the specified item. THe result will only be accurate if all items have the same height.
|
// ScrollTo scrolls to the specified item.
|
||||||
// Otherwise, it will be approximate.
|
|
||||||
func (l *List) ScrollTo(n int) {
|
func (l *List) ScrollTo(n int) {
|
||||||
l.Position.First = n
|
l.Position.First = n
|
||||||
l.Position.Offset = 0
|
l.Position.Offset = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user