(ScrollView) If animation duration is 0, then return final position in completed... 72/24172/1
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 18 Jun 2014 10:12:53 +0000 (19:12 +0900)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 8 Jul 2014 17:47:11 +0000 (18:47 +0100)
[problem]     If the animation duration is 0, we still return the current scroll position. This is
              wrong as in the next frame, we will be at the requested position.
[cause]       N/A
[solution]    If we do not kick off an animation, then we should check whether the duration was 0.
              If it was, we should return the target-position instead.

Change-Id: I3e1a96b3de7ca2685a16f6dd6b8ce5aebc1c78af
Signed-off-by: Adeel Kazmi <adeel.kazmi@samsung.com>
base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp

index 7b0a68f..160546a 100644 (file)
@@ -1313,9 +1313,18 @@ void ScrollView::TransformTo(const Vector3& position, const Vector3& scale, floa
     // if not animating, then this pan has completed right now.
     Self().SetProperty(mPropertyScrolling, false);
     mScrolling = false;
     // if not animating, then this pan has completed right now.
     Self().SetProperty(mPropertyScrolling, false);
     mScrolling = false;
-    DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignalV2 2 [%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y);
+
+    // If we have no duration, then in the next update frame, we will be at the position specified as we just set.
+    // In this scenario, we cannot return the currentScrollPosition as this is out-of-date and should instead return the requested final position
+    Vector3 completedPosition( currentScrollPosition );
+    if( duration <= Math::MACHINE_EPSILON_10 )
+    {
+      completedPosition = position;
+    }
+
+    DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignalV2 2 [%.2f, %.2f]", this, completedPosition.x, completedPosition.y);
     SetScrollUpdateNotification(false);
     SetScrollUpdateNotification(false);
-    mScrollCompletedSignalV2.Emit( currentScrollPosition );
+    mScrollCompletedSignalV2.Emit( completedPosition );
   }
 }
 
   }
 }