-void ScrollView::SetOvershootToOrigin()
-{
- // Clear Snap animation if exists.
- if(mSnapOvershootAnimation)
- {
- mSnapOvershootAnimation.FinishedSignal().Disconnect(this, &ScrollView::OnSnapOvershootAnimationFinished);
- mSnapOvershootAnimation.Stop();
- mSnapOvershootAnimation.Clear();
- mSnapOvershootAnimation = NULL;
- }
- SetOvershootConstraintsEnabled(false);
- Self().SetProperty(mPropertyOvershootX, 0.0f);
- Self().SetProperty(mPropertyOvershootY, 0.0f);
-}
-
-void ScrollView::AnimateOvershootToOrigin(float xDelay, float yDelay)
-{
- if( IsScrollComponentEnabled(Toolkit::Scrollable::OvershootIndicator) )
- {
- if(xDelay < Math::MACHINE_EPSILON_1)
- {
- // kick start animation to 0
- Self().SetProperty(mPropertyOvershootX, 0.0f);
- }
- if(yDelay < Math::MACHINE_EPSILON_1)
- {
- // kick start animation to 0
- Self().SetProperty(mPropertyOvershootY, 0.0f);
- }
- return;
- }
- // When we need to animate overshoot to 0
- if(mSnapOvershootDuration > Math::MACHINE_EPSILON_1)
- {
- Actor self = Self();
- // Clear Snap animation if exists.
- if(mSnapOvershootAnimation)
- {
- mSnapOvershootAnimation.FinishedSignal().Disconnect( this, &ScrollView::OnSnapOvershootAnimationFinished );
- mSnapOvershootAnimation.Stop();
- mSnapOvershootAnimation.Clear();
- mSnapOvershootAnimation = NULL;
- }
- if(!mSnapXAnimation && mScrollMainInternalOvershootXConstraint)
- {
- // need to remove the x overshoot constraint now or it will override animation to 0
- Self().RemoveConstraint(mScrollMainInternalOvershootXConstraint);
- mScrollMainInternalOvershootXConstraint.Reset();
- mScrollMainInternalOvershootXConstraint = 0;
- }
- if(!mSnapYAnimation && mScrollMainInternalOvershootYConstraint)
- {
- // need to remove the y overshoot constraint now or it will override animation to 0
- Self().RemoveConstraint(mScrollMainInternalOvershootYConstraint);
- mScrollMainInternalOvershootYConstraint.Reset();
- mScrollMainInternalOvershootYConstraint = 0;
- }
- // setup the new overshoot to 0 animation
- float totalDuration = (xDelay > yDelay ? xDelay : yDelay) + mSnapOvershootDuration;
- mSnapOvershootAnimation = Animation::New(totalDuration);
- mSnapOvershootAnimation.FinishedSignal().Connect( this, &ScrollView::OnSnapOvershootAnimationFinished );
-
- mSnapOvershootAnimation.AnimateTo( Property(self, mPropertyOvershootX), 0.0f, mSnapOvershootAlphaFunction, TimePeriod(xDelay, mSnapOvershootDuration) );
- mSnapOvershootAnimation.AnimateTo( Property(self, mPropertyOvershootY), 0.0f, mSnapOvershootAlphaFunction, TimePeriod(yDelay, mSnapOvershootDuration) );
-
- mSnapOvershootAnimation.SetDuration(totalDuration);
- mSnapOvershootAnimation.Play();
- }
- else
- {
- SetOvershootToOrigin();
- }
-}
-
-void ScrollView::OnSnapOvershootAnimationFinished( Animation& source )
-{
- mSnapOvershootAnimation = NULL;
-}
-