Skip to content

Commit

Permalink
Always refresh a changed scroll value, even if there's no scrollbar
Browse files Browse the repository at this point in the history
See Textualize#1201.

See
Textualize#1201 (comment)
though -- there has been internal discussion about how there may be a need
to even inhibit by-code scrolling (as opposed to by-input) scrolling, in
some situations. This would likely require that there's something
higher-level, perhaps, that doesn't even attempt to animate `scroll_x` or
`scroll_y` in the first place.

Consider this a placeholder approach for the moment.
  • Loading branch information
davep committed Jan 12, 2023
1 parent 328733e commit f44d483
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/textual/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,14 +805,14 @@ def watch_hover_style(
def watch_scroll_x(self, old_value: float, new_value: float) -> None:
if self.show_horizontal_scrollbar:
self.horizontal_scrollbar.position = round(new_value)
if round(old_value) != round(new_value):
self._refresh_scroll()
if round(old_value) != round(new_value):
self._refresh_scroll()

def watch_scroll_y(self, old_value: float, new_value: float) -> None:
if self.show_vertical_scrollbar:
self.vertical_scrollbar.position = round(new_value)
if round(old_value) != round(new_value):
self._refresh_scroll()
if round(old_value) != round(new_value):
self._refresh_scroll()

def validate_scroll_x(self, value: float) -> float:
return clamp(value, 0, self.max_scroll_x)
Expand Down

0 comments on commit f44d483

Please sign in to comment.