smoother animation with roundering

This commit is contained in:
Will McGugan
2023-01-08 16:53:06 +00:00
parent 80a33c074b
commit 958b6d1439

View File

@@ -804,14 +804,14 @@ class Widget(DOMNode):
def watch_scroll_x(self, old_value: float, new_value: float) -> None:
if self.show_horizontal_scrollbar:
self.horizontal_scrollbar.position = int(new_value)
if int(old_value) != int(new_value):
self.horizontal_scrollbar.position = round(new_value)
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 = int(new_value)
if int(old_value) != int(new_value):
self.vertical_scrollbar.position = round(new_value)
if round(old_value) != round(new_value):
self._refresh_scroll()
def validate_scroll_x(self, value: float) -> float:
@@ -1149,7 +1149,7 @@ class Widget(DOMNode):
Returns:
Offset: Offset a container has been scrolled by.
"""
return Offset(int(self.scroll_x), int(self.scroll_y))
return Offset(round(self.scroll_x), round(self.scroll_y))
@property
def is_transparent(self) -> bool: