Fix Scrolling to Specific Element in ScrollView
authorjh5.cho <jh5.cho@samsung.com>
Mon, 26 Dec 2016 08:06:19 +0000 (17:06 +0900)
committerKangho Hur <kangho.hur@samsung.com>
Fri, 24 Mar 2017 04:18:58 +0000 (13:18 +0900)
    - Add the calculation code for getting coordination of given Element
      : ScrollToAsync() which has Element parameter did not work.
        It always scroll to (0,0) because there were no calculation code for Element.

TASK=TCAPI-2174

Change-Id: I6f3fbdbd060b1c74bc89c25e7e46d99cf10fbf51

Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs

index a566f24..1119538 100755 (executable)
@@ -123,7 +123,16 @@ namespace Xamarin.Forms.Platform.Tizen
 
                void ScrollRequestHandler(object sender, ScrollToRequestedEventArgs e)
                {
-                       Rect region = new Rect(ToNativeDimension(e.ScrollX), ToNativeDimension(e.ScrollY), ToNativeDimension(Element.Width), ToNativeDimension(Element.Height));
+                       var x = e.ScrollX;
+                       var y = e.ScrollY;
+                       if (e.Mode == ScrollToMode.Element)
+                       {
+                               Point itemPosition = (Element as IScrollViewController).GetScrollPositionForElement(e.Element as VisualElement, e.Position);
+                               x = itemPosition.X;
+                               y = itemPosition.Y;
+                       }
+
+                       Rect region = new Rect(ToNativeDimension(x), ToNativeDimension(y), ToNativeDimension(Element.Width), ToNativeDimension(Element.Height));
                        Control.ScrollTo(region, e.ShouldAnimate);
                }
        }