Skip to content

Commit

Permalink
Update scroll container content if it is changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Sep 26, 2020
1 parent f326d46 commit e570a36
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions widget/scroller.go
Expand Up @@ -279,6 +279,10 @@ func (r *scrollContainerRenderer) MinSize() fyne.Size {
}

func (r *scrollContainerRenderer) Refresh() {
if len(r.BaseRenderer.Objects()) == 0 || r.BaseRenderer.Objects()[0] != r.scroll.Content {
// push updated content object to baseRenderer
r.BaseRenderer.SetObjects([]fyne.CanvasObject{r.scroll.Content})
}
if r.oldMinSize == r.scroll.Content.MinSize() && r.scroll.Content.Size() == r.oldMinSize {
r.layoutBars(r.scroll.Size())
return
Expand Down
5 changes: 5 additions & 0 deletions widget/scroller_test.go
Expand Up @@ -163,6 +163,11 @@ func TestScrollContainer_Refresh(t *testing.T) {
Refresh(scroll)
assert.Equal(t, 400, scroll.Offset.X)
assert.Equal(t, fyne.NewSize(500, 500), rect.Size())

rect2 := canvas.NewRectangle(color.White)
scroll.Content = rect2
scroll.Refresh()
assert.Equal(t, rect2, test.WidgetRenderer(scroll).Objects()[0])
}

func TestScrollContainer_Scrolled(t *testing.T) {
Expand Down

0 comments on commit e570a36

Please sign in to comment.