Пример #1
0
        PanInfo PanLeftResultInfoForVelocity(CGPoint velocity)
        {
            nfloat ThresholdVelocity = 1000.0f;
            nfloat PointOfNoReturn   = (nfloat)Math.Floor(LeftMinOrigin()) + SlideMenuOptions.PointOfNoReturnWidth;
            nfloat LeftOrigin        = LeftContainerView.Frame.X;

            PanInfo panInfo = new PanInfo();

            panInfo.action       = SlideAction.Close;
            panInfo.ShouldBounce = false;
            panInfo.Velocity     = 0.0f;

            panInfo.action = LeftOrigin <= PointOfNoReturn ? SlideAction.Close : SlideAction.Open;

            if (velocity.X >= ThresholdVelocity)
            {
                panInfo.action   = SlideAction.Open;
                panInfo.Velocity = velocity.X;
            }
            else if (velocity.X <= (-1.0 * ThresholdVelocity))
            {
                panInfo.action   = SlideAction.Close;
                panInfo.Velocity = velocity.X;
            }

            return(panInfo);
        }
Пример #2
0
        PanInfo PanRightResultInfoForVelocity(CGPoint velocity)
        {
            nfloat ThresholdVelocity = -1000.0f;
            nfloat PointOfNoReturn   = (nfloat)Math.Floor(View.Bounds.Width) - SlideMenuOptions.PointOfNoReturnWidth;
            nfloat RightOrigin       = RightContainerView.Frame.X;

            PanInfo panInfo = new PanInfo();

            panInfo.action       = SlideAction.Close;
            panInfo.ShouldBounce = false;
            panInfo.Velocity     = 0.0f;

            panInfo.action = RightOrigin >= PointOfNoReturn ? SlideAction.Close : SlideAction.Open;

            if (velocity.X <= ThresholdVelocity)
            {
                panInfo.action   = SlideAction.Open;
                panInfo.Velocity = velocity.X;
            }
            else if (velocity.X >= (-1.0 * ThresholdVelocity))
            {
                panInfo.action   = SlideAction.Close;
                panInfo.Velocity = velocity.X;
            }

            return(panInfo);
        }
Пример #3
0
        public void HandleRightPanGesture(UIPanGestureRecognizer panGesture)
        {
            if (!IsTargetViewController())
            {
                return;
            }

            if (IsLeftOpen())
            {
                return;
            }


            switch (panGesture.State)
            {
            case UIGestureRecognizerState.Began:

                if (RightPanState.LastState != UIGestureRecognizerState.Ended &&
                    RightPanState.LastState != UIGestureRecognizerState.Cancelled &&
                    RightPanState.LastState != UIGestureRecognizerState.Failed)
                {
                    return;
                }

                if (IsRightHidden() && RightWillOpen != null)
                {
                    RightWillOpen();
                }
                else if (RightWillClose != null)
                {
                    RightWillClose();
                }

                RightPanState.FrameAtStartOfPan     = RightContainerView.Frame;
                RightPanState.StartPointOfPan       = panGesture.LocationInView(View);
                RightPanState.WasOpenAtStartOfPan   = IsRightOpen();
                RightPanState.WasHiddenAtStartOfPan = IsRightHidden();

                if (RightViewController != null)
                {
                    RightViewController.BeginAppearanceTransition(RightPanState.WasHiddenAtStartOfPan, true);
                }

                AddShadowToView(RightContainerView);
                SetOpenWindowLevel();

                break;

            case UIGestureRecognizerState.Changed:

                if (RightPanState.LastState != UIGestureRecognizerState.Began &&
                    RightPanState.LastState != UIGestureRecognizerState.Changed)
                {
                    return;
                }

                CGPoint Translation = panGesture.TranslationInView(panGesture.View);
                RightContainerView.Frame = ApplyRightTranslation(Translation, RightPanState.FrameAtStartOfPan);
                ApplyRightOpacity();
                ApplyRightContentViewScale();

                break;

            case UIGestureRecognizerState.Ended:
            case UIGestureRecognizerState.Cancelled:

                if (RightPanState.LastState != UIGestureRecognizerState.Changed)
                {
                    SetCloseWindowLevel();
                    return;
                }

                CGPoint Velocity = panGesture.VelocityInView(panGesture.View);
                PanInfo panInfo  = PanRightResultInfoForVelocity(Velocity);

                if (panInfo.action == SlideAction.Open)
                {
                    if (!RightPanState.WasHiddenAtStartOfPan && RightViewController != null)
                    {
                        RightViewController.BeginAppearanceTransition(true, true);
                    }
                    OpenRightWithVelocity(panInfo.Velocity);
                    Track(TrackAction.RightFlickOpen);
                }
                else
                {
                    if (!RightPanState.WasHiddenAtStartOfPan && RightViewController != null)
                    {
                        RightViewController.BeginAppearanceTransition(false, true);
                    }
                    CloseRightWithVelocity(panInfo.Velocity);
                    SetCloseWindowLevel();
                    Track(TrackAction.RightFlickClose);
                }

                break;

            case UIGestureRecognizerState.Failed:
            case UIGestureRecognizerState.Possible:
                break;
            }

            RightPanState.LastState = panGesture.State;
        }