Esempio n. 1
0
        /// <summary>
        /// Animate Fling of viewport
        /// </summary>
        /// <param name="velocityX">VelocityX from SwipedEventArgs></param>
        /// <param name="velocityY">VelocityX from SwipedEventArgs></param>
        /// <param name="maxDuration">Maximum duration of fling deceleration></param>
        public void FlingWith(double velocityX, double velocityY, long maxDuration)
        {
            var response = FlingAnimation.Create(velocityX, velocityY, maxDuration);

            _viewport.SetAnimations(response.Entries);
            OnNavigated(response.Duration, ChangeType.Discrete);
        }
Esempio n. 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Main);

            View viewSpring = FindViewById <View>(Resource.Id.view_spring);
            View viewFling  = FindViewById <View>(Resource.Id.view_fling);

            viewSpring.Click += (o, e) =>
            {
                SpringAnimation springAnim = new SpringAnimation(viewSpring, DynamicAnimation.TranslationY, 0);
                springAnim.Spring.SetStiffness(SpringForce.StiffnessLow);
                springAnim.Spring.SetDampingRatio(SpringForce.DampingRatioHighBouncy);
                springAnim.SetStartVelocity(DpToPx(-2000));
                springAnim.Start();
            };

            viewFling.Click += (o, e) =>
            {
                FlingAnimation flingAnim = new FlingAnimation(viewFling, DynamicAnimation.TranslationY);
                flingAnim.SetStartVelocity(DpToPx(shouldFlingUpwards ? -1500 : 1500));
                //flingAnim.SetFriction(2);
                flingAnim.Start();
                shouldFlingUpwards = !shouldFlingUpwards;
            };
        }
        public virtual void RunAnimation(View View, float distance)
        {
            var flingAnimation = new FlingAnimation(View, DynamicAnimation.TranslationX);

            flingAnimation.SetStartVelocity(distance);
            flingAnimation.SetFriction(2);
            flingAnimation.Start();
        }
Esempio n. 4
0
 /// <summary>
 /// Animate Fling of viewport
 /// </summary>
 /// <param name="velocityX">VelocityX from SwipedEventArgs></param>
 /// <param name="velocityY">VelocityX from SwipedEventArgs></param>
 /// <param name="maxDuration">Maximum duration of fling deceleration></param>
 public void FlingWith(double velocityX, double velocityY, long maxDuration)
 {
     _viewport.SetAnimations(FlingAnimation.Create(velocityX, velocityY, maxDuration));
 }