Beispiel #1
0
        private async void OnDrag(object sender, PanUpdatedEventArgs e)
        {
            if (!m_sheetBehaviour.IsDraggable)
            {
                return;
            }
            if (m_newY == 0)
            {
                m_newY = SheetFrame.TranslationY;              //This variable is used to fix a iOS issue where an view element that you have a pan gesture on it and that is translating the same view element jitters
            }
            switch (e.StatusType)
            {
            case GestureStatus.Started:
                m_sheetBehaviour.IsDragging = true;
                break;

            case GestureStatus.Running:

                var translationY = Device.RuntimePlatform == Device.Android ? OuterSheetFrame.TranslationY : m_newY;
                m_newYTranslation = e.TotalY + translationY;
                //Hack to remove jitter from android
                if (Device.RuntimePlatform == Device.Android)
                {
                    e = new PanUpdatedEventArgs(e.StatusType, e.GestureId, 0, m_newYTranslation);
                    m_newYTranslation = e.TotalY;
                }
                break;

            case GestureStatus.Completed:
                m_sheetBehaviour.IsDragging = false;
                //Snap?
                break;

            case GestureStatus.Canceled:
                m_sheetBehaviour.IsDragging = false;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            if (e.StatusType != GestureStatus.Started)
            {
                await m_sheetBehaviour.UpdatePosition(m_newYTranslation);

                if (e.StatusType == GestureStatus.Completed) //Makes sure the jitter is removed on iOS
                {
                    m_newY = SheetFrame.TranslationY;
                }
            }
        }
        private void OnDrag(object sender, PanUpdatedEventArgs e)
        {
            if (!m_sheetBehaviour.IsDraggable)
            {
                return;
            }
            if (m_newY == 0)
            {
                m_newY = SheetFrame.TranslationY;
            }

            switch (e.StatusType)
            {
            case GestureStatus.Started:
                m_sheetBehaviour.IsDragging = true;
                break;

            case GestureStatus.Running:

                var translationY    = (Device.RuntimePlatform == Device.Android) ? OuterSheetFrame.TranslationY : m_newY;
                var newYTranslation = e.TotalY + translationY;
                //Hack to remove jitter from android
                if (Device.RuntimePlatform == Device.Android)
                {
                    e = new PanUpdatedEventArgs(e.StatusType, e.GestureId, 0, newYTranslation);
                    newYTranslation = e.TotalY;
                }

                m_sheetBehaviour.UpdatePosition(newYTranslation);
                break;

            case GestureStatus.Completed:
                m_newY = SheetFrame.TranslationY;
                m_sheetBehaviour.IsDragging = false;
                //Snap?
                break;

            case GestureStatus.Canceled:
                m_sheetBehaviour.IsDragging = false;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }