[NUI] There was a problem calculating the scroll position.
authorjoogab.yun <joogab.yun@samsung.com>
Mon, 9 May 2022 09:43:35 +0000 (18:43 +0900)
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>
Tue, 10 May 2022 06:09:58 +0000 (15:09 +0900)
It caused unnecessary scrolling even when it wasn't necessary.
Change it to scroll only when needed.

src/Tizen.NUI.Components/Controls/ScrollableBase.cs

index 07454e9..d25ef97 100755 (executable)
@@ -1852,42 +1852,38 @@ namespace Tizen.NUI.Components
                 {
                     // Check next focused view is inside of visible area.
                     // If it is not, move scroll position to make it visible.
-                    Vector2 scrollPosition = ContentContainer.ScreenPosition;
-                    float targetPosition = -(ScrollingDirection == Direction.Horizontal ? scrollPosition.X : scrollPosition.Y);
-
                     float left = nextFocusedView.ScreenPosition.X;
                     float right = nextFocusedView.ScreenPosition.X + nextFocusedView.Size.Width;
                     float top = nextFocusedView.ScreenPosition.Y;
                     float bottom = nextFocusedView.ScreenPosition.Y + nextFocusedView.Size.Height;
 
-                    float visibleRectangleLeft = scrollPosition.X;
-                    float visibleRectangleRight = scrollPosition.X + Size.Width;
-                    float visibleRectangleTop = scrollPosition.Y;
-                    float visibleRectangleBottom = scrollPosition.Y + Size.Height;
+                    float visibleRectangleLeft = ScreenPosition.X;
+                    float visibleRectangleRight = ScreenPosition.X + Size.Width;
+                    float visibleRectangleTop = ScreenPosition.Y;
+                    float visibleRectangleBottom = ScreenPosition.Y + Size.Height;
 
                     if (ScrollingDirection == Direction.Horizontal)
                     {
                         if (left < visibleRectangleLeft)
                         {
-                            targetPosition = left - scrollPosition.X;
+                            ScrollTo(left- ContentContainer.ScreenPosition.X, true);
                         }
                         else if (right > visibleRectangleRight)
                         {
-                            targetPosition = right - Size.Width - scrollPosition.X;
+                            ScrollTo(right - Size.Width - ContentContainer.ScreenPosition.Y, true);
                         }
                     }
                     else
                     {
                         if (top < visibleRectangleTop)
                         {
-                            targetPosition = top - scrollPosition.Y;
+                            ScrollTo(top - ContentContainer.ScreenPosition.Y, true);
                         }
                         else if (bottom > visibleRectangleBottom)
                         {
-                            targetPosition = bottom - Size.Height - scrollPosition.Y;
+                            ScrollTo(bottom - Size.Height - ContentContainer.ScreenPosition.Y, true);
                         }
                     }
-                    ScrollTo(targetPosition, true);
                 }
             }
             return nextFocusedView;