void listener_Flick(object sender, FlickGestureEventArgs e)
        {
            //Debug.WriteLine("listener_Flick");

            if (e.Direction == Orientation.Vertical)
            {
                _state = State.Flicking;

                _selectedItem = null;
                if (!IsExpanded)
                {
                    IsExpanded = true;
                }

                Point           velocity      = new Point(0, e.VerticalVelocity);
                double          flickDuration = PhysicsConstants.GetStopTime(velocity);
                Point           flickEndPoint = PhysicsConstants.GetStopPoint(velocity);
                IEasingFunction flickEase     = PhysicsConstants.GetEasingFunction(flickDuration);

                AnimatePanel(new Duration(TimeSpan.FromSeconds(flickDuration)), flickEase, _panningTransform.Y + flickEndPoint.Y);

                e.Handled = true;

                _selectedItem = null;
                UpdateItemState();
            }
        }
        private void OnManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
        {
            if (_isDragging)
            {
                // See if it was a flick
                if (e.IsInertial)
                {
                    _state        = State.Flicking;
                    _selectedItem = null;

                    if (!IsExpanded)
                    {
                        IsExpanded = true;
                    }

                    Point velocity;

                    if (Orientation == Orientation.Vertical)
                    {
                        velocity = new Point(0, e.FinalVelocities.LinearVelocity.Y);
                    }
                    else
                    {
                        velocity = new Point(e.FinalVelocities.LinearVelocity.X, 0);
                    }

                    double          flickDuration = PhysicsConstants.GetStopTime(velocity, Friction, MaximumSpeed, ParkingSpeed);
                    Point           flickEndPoint = PhysicsConstants.GetStopPoint(velocity, Friction, MaximumSpeed, ParkingSpeed);
                    IEasingFunction flickEase     = PhysicsConstants.GetEasingFunction(flickDuration, Friction);

                    double to;
                    if (Orientation == Orientation.Vertical)
                    {
                        to = _panningTransform.Y + flickEndPoint.Y;
                    }
                    else
                    {
                        to = _panningTransform.X + flickEndPoint.X;
                    }

                    AnimatePanel(new Duration(TimeSpan.FromSeconds(flickDuration)), flickEase, to);

                    e.Handled = true;

                    _selectedItem = null;
                    UpdateItemState();
                }

                if (_state == State.Dragging)
                {
                    SelectAndSnapToClosest();
                }

                _state = State.Expanded;
            }
        }
Example #3
0
        private void OnManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
        {
            if (_isDragging)
            {
                // See if it was a flick
                if (e.IsInertial)
                {
                    _state        = State.Flicking;
                    _selectedItem = null;

                    if (!IsExpanded)
                    {
                        IsExpanded = true;
                    }

                    Point           velocity      = new Point(0, e.FinalVelocities.LinearVelocity.Y);
                    double          flickDuration = PhysicsConstants.GetStopTime(velocity);
                    Point           flickEndPoint = PhysicsConstants.GetStopPoint(velocity);
                    IEasingFunction flickEase     = PhysicsConstants.GetEasingFunction(flickDuration);

                    double endPoint         = _panningTransform.Y + flickEndPoint.Y;
                    double adjustedEndPoint = Math.Round(endPoint / ActualItemHeight) * ActualItemHeight;

                    flickDuration *= adjustedEndPoint / endPoint;

                    AnimatePanel(new Duration(TimeSpan.FromSeconds(flickDuration)), flickEase, adjustedEndPoint);

#if WP8
                    _changeStateAfterAnimation = false;
#endif

                    e.Handled = true;

                    _selectedItem = null;
                    UpdateItemState();
                }

                if (_state == State.Dragging)
                {
                    SelectAndSnapToClosest();
                }

                _state = State.Expanded;
            }
        }