[NUI] Support vertical direction page snap (#2676)
authorWoochan <48237284+lwc0917@users.noreply.github.com>
Tue, 2 Mar 2021 07:06:34 +0000 (16:06 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 3 Mar 2021 07:56:53 +0000 (16:56 +0900)
This patch fixes an issue that the page snap feature not working for vertical direction.

Co-authored-by: Woochanlee <wc0917.lee@samsung.com>
Co-authored-by: huiyueun <35286162+huiyueun@users.noreply.github.com>
Co-authored-by: Jiyun Yang <ji.yang@samsung.com>
src/Tizen.NUI.Components/Controls/ScrollableBase.cs

index f68bb49..c77c736 100755 (executable)
@@ -1009,6 +1009,8 @@ namespace Tizen.NUI.Components
 
         private void PageSnap(float velocity)
         {
+            float destination;
+
             Debug.WriteLineIf(LayoutDebugScrollableBase, "PageSnap with pan candidate totalDisplacement:" + totalDisplacementForPan +
                 " currentPage[" + CurrentPage + "]");
 
@@ -1037,9 +1039,12 @@ namespace Tizen.NUI.Components
             }
 
             // Animate to new page or reposition to current page
-            float destinationX = -(Children[CurrentPage].Position.X + Children[CurrentPage].CurrentSize.Width / 2 - CurrentSize.Width / 2); // set to middle of current page
-            Debug.WriteLineIf(LayoutDebugScrollableBase, "Snapping to page[" + CurrentPage + "] to:" + destinationX + " from:" + ContentContainer.PositionX);
-            AnimateChildTo(ScrollDuration, destinationX);
+            if (ScrollingDirection == Direction.Horizontal)
+                destination = -(Children[CurrentPage].Position.X + Children[CurrentPage].CurrentSize.Width / 2 - CurrentSize.Width / 2); // set to middle of current page
+            else
+                destination = -(Children[CurrentPage].Position.Y + Children[CurrentPage].CurrentSize.Height / 2 - CurrentSize.Height / 2);
+
+            AnimateChildTo(ScrollDuration, destination);
         }
 
         /// <summary>