Browse Source

Round scroll offset clamping

Michael Ragazzon 1 year ago
parent
commit
172e073469
1 changed files with 4 additions and 4 deletions
  1. 4 4
      Source/Core/Element.cpp

+ 4 - 4
Source/Core/Element.cpp

@@ -919,7 +919,7 @@ float Element::GetScrollLeft()
 
 
 void Element::SetScrollLeft(float scroll_left)
 void Element::SetScrollLeft(float scroll_left)
 {
 {
-	const float new_offset = Math::Clamp(Math::Round(scroll_left), 0.0f, GetScrollWidth() - GetClientWidth());
+	const float new_offset = Math::Round(Math::Clamp(scroll_left, 0.0f, GetScrollWidth() - GetClientWidth()));
 	if (new_offset != scroll_offset.x)
 	if (new_offset != scroll_offset.x)
 	{
 	{
 		scroll_offset.x = new_offset;
 		scroll_offset.x = new_offset;
@@ -937,7 +937,7 @@ float Element::GetScrollTop()
 
 
 void Element::SetScrollTop(float scroll_top)
 void Element::SetScrollTop(float scroll_top)
 {
 {
-	const float new_offset = Math::Clamp(Math::Round(scroll_top), 0.0f, GetScrollHeight() - GetClientHeight());
+	const float new_offset = Math::Round(Math::Clamp(Math::Round(scroll_top), 0.0f, GetScrollHeight() - GetClientHeight()));
 	if (new_offset != scroll_offset.y)
 	if (new_offset != scroll_offset.y)
 	{
 	{
 		scroll_offset.y = new_offset;
 		scroll_offset.y = new_offset;
@@ -2925,8 +2925,8 @@ void Element::DirtyFontFaceRecursive()
 void Element::ClampScrollOffset()
 void Element::ClampScrollOffset()
 {
 {
 	const Vector2f new_scroll_offset = {
 	const Vector2f new_scroll_offset = {
-		Math::Min(scroll_offset.x, GetScrollWidth() - GetClientWidth()),
-		Math::Min(scroll_offset.y, GetScrollHeight() - GetClientHeight()),
+		Math::Round(Math::Min(scroll_offset.x, GetScrollWidth() - GetClientWidth())),
+		Math::Round(Math::Min(scroll_offset.y, GetScrollHeight() - GetClientHeight())),
 	};
 	};
 
 
 	if (new_scroll_offset != scroll_offset)
 	if (new_scroll_offset != scroll_offset)