Skip to content

Commit 61fffb9

Browse files
authored
ui: avoid rendering off-viewport items in Scroller (#36659)
avoid rendering off-viewport items in Scroller
1 parent a46af06 commit 61fffb9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

system/ui/widgets/scroller.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ def _get_scroll(self, visible_items: list[Widget], content_size: float) -> float
161161
return self.scroll_panel.get_offset()
162162

163163
def _render(self, _):
164-
# TODO: don't draw items that are not in the viewport
165164
visible_items = [item for item in self._items if item.is_visible]
166165

167166
# Add line separator between items
@@ -219,6 +218,10 @@ def _render(self, _):
219218
item.set_position(round(x), round(y)) # round to prevent jumping when settling
220219
item.set_parent_rect(self._rect)
221220

221+
# Skip rendering if not in viewport
222+
if not rl.check_collision_recs(item.rect, self._rect):
223+
continue
224+
222225
# Scale each element around its own origin when scrolling
223226
scale = self._zoom_filter.x
224227
rl.rl_push_matrix()

0 commit comments

Comments
 (0)