[NUI] Fix ScrollTo to move pan position to the argument position (#1652)
authorjaehyun0cho <jaehyun0cho@gmail.com>
Thu, 4 Jun 2020 04:43:37 +0000 (13:43 +0900)
committerGitHub <noreply@github.com>
Thu, 4 Jun 2020 04:43:37 +0000 (13:43 +0900)
Previously, ScrollTo moved pan position including the ScrollableBase's
current position.
e.g. ScrollTo(360, true); //moves by 360
     ScrollTo(0, true); //moves by 360 again based on current position

The argument position is the new pan position. So the new position of
ScrollableBase becomes (-position).
To move ScrollableBase's position to (-position), it moves by
(-position - currentPosition).

Co-authored-by: Jaehyun Cho <jae_hyun.cho@samsung.com>
src/Tizen.NUI.Components/Controls/ScrollableBase.cs

index 54dcbfd..952f032 100755 (executable)
@@ -591,7 +591,9 @@ namespace Tizen.NUI.Components
             float currentPositionX = mScrollingChild.CurrentPosition.X != 0 ? mScrollingChild.CurrentPosition.X : mScrollingChild.Position.X;
             float currentPositionY = mScrollingChild.CurrentPosition.Y != 0 ? mScrollingChild.CurrentPosition.Y : mScrollingChild.Position.Y;
             float delta = ScrollingDirection == Direction.Horizontal ? currentPositionX : currentPositionY;
-            delta -= position;
+            // The argument position is the new pan position. So the new position of ScrollableBase becomes (-position).
+            // To move ScrollableBase's position to (-position), it moves by (-position - currentPosition).
+            delta = -position - delta;
 
             ScrollBy(delta, animate);
         }