コード例 #1
0
        void ProcessTouchMove(CGPoint point)
        {
            if (!_isSwiping)
            {
                _swipeDirection = SwipeDirectionHelper.GetSwipeDirection(new Point(_initialPoint.X, _initialPoint.Y), new Point(point.X, point.Y));
                RaiseSwipeStarted();
                _isSwiping = true;
            }

            if (!ValidateSwipeDirection())
            {
                return;
            }

            _swipeOffset = GetSwipeOffset(_initialPoint, point);

            UpdateSwipeItems();

            if (Math.Abs(_swipeOffset) > double.Epsilon)
            {
                Swipe();
            }
            else
            {
                ResetSwipe();
            }

            RaiseSwipeChanging();
        }
コード例 #2
0
        bool ProcessTouchMove(APointF point)
        {
            if (_contentView == null || !TouchInsideContent(point))
            {
                return(false);
            }

            if (!_isSwiping && _swipeThreshold == 0)
            {
                _swipeDirection = SwipeDirectionHelper.GetSwipeDirection(new Point(_initialPoint.X, _initialPoint.Y), new Point(point.X, point.Y));
                RaiseSwipeStarted();
                _isSwiping = true;
            }

            if (!ValidateSwipeDirection())
            {
                return(false);
            }

            _swipeOffset = GetSwipeOffset(_initialPoint, point);
            UpdateSwipeItems();

            if (Math.Abs(_swipeOffset) > double.Epsilon)
            {
                Swipe();
            }
            else
            {
                ResetSwipe();
            }

            RaiseSwipeChanging();

            return(true);
        }
コード例 #3
0
        private void OnEnd(GestureLayer.MomentumData moment)
        {
            var direction = SwipeDirectionHelper.GetSwipeDirection(new Point(moment.X1, moment.Y1), new Point(moment.X2, moment.Y2));

            var swipeDirection = direction == SwipeDirection.Left
                ? ItemSwipeDirection.Left
                                : direction == SwipeDirection.Right
                                    ? ItemSwipeDirection.Right
                                    : direction == SwipeDirection.Up
                                        ? ItemSwipeDirection.Up
                                        : ItemSwipeDirection.Down;

            CardsViewElement?.OnSwiped(swipeDirection);
        }
コード例 #4
0
        bool ProcessTouchMove(APointF point)
        {
            if (_contentView == null || !TouchInsideContent(point))
            {
                return(false);
            }

            var swipeDirection = _swipeDirection;

            if (!_isOpen && !_isResettingSwipe)
            {
                swipeDirection = SwipeDirectionHelper.GetSwipeDirection(new Point(_initialPoint.X, _initialPoint.Y), new Point(point.X, point.Y));
            }

            if (_swipeDirection != swipeDirection)
            {
                _swipeDirection = swipeDirection;

                if (!_isOpen)
                {
                    DisposeSwipeItems();
                    UpdateSwipeItems();
                }
            }

            if (!_isSwiping)
            {
                RaiseSwipeStarted();
                _isSwiping = true;
            }

            if (!ValidateSwipeDirection() || _isResettingSwipe)
            {
                return(false);
            }

            _swipeOffset = GetSwipeOffset(_initialPoint, point);

            UpdateSwipeItems();

            if (Math.Abs(_swipeOffset) > double.Epsilon)
            {
                Swipe();
            }

            RaiseSwipeChanging();

            return(true);
        }
コード例 #5
0
ファイル: MauiSwipeView.cs プロジェクト: josephwambura/maui
        bool ProcessTouchMove(APointF point)
        {
            if (_contentView == null || !TouchInsideContent(point) || _initialPoint == null)
            {
                return(false);
            }

            if (!_isOpen)
            {
                ResetSwipeToInitialPosition();

                _swipeDirection = SwipeDirectionHelper.GetSwipeDirection(new Point(_initialPoint.X, _initialPoint.Y), new Point(point.X, point.Y));

                UpdateSwipeItems();
            }

            if (!_isSwiping)
            {
                RaiseSwipeStarted();
                _isSwiping = true;
            }

            if (!ValidateSwipeDirection() || _isResettingSwipe)
            {
                return(false);
            }

            EnableParentGesture(false);
            _swipeOffset = GetSwipeOffset(_initialPoint, point);
            UpdateIsOpen(_swipeOffset != 0);

            UpdateSwipeItems();

            if (Math.Abs(_swipeOffset) > double.Epsilon)
            {
                Swipe();
            }

            RaiseSwipeChanging();

            return(true);
        }
コード例 #6
0
ファイル: SwipeViewRenderer.cs プロジェクト: sung-su/maui
        void OnMoved(GestureLayer.MomentumData moment)
        {
            if (SwipeDirection == 0)
            {
                var direction = SwipeDirectionHelper.GetSwipeDirection(new Graphics.Point(moment.X1, moment.Y1), new Graphics.Point(moment.X2, moment.Y2));

                if (HasRightItems && direction == SwipeDirection.Left)
                {
                    SwipeDirection = SwipeDirection.Left;
                }
                else if (HasLeftItems && direction == SwipeDirection.Right)
                {
                    SwipeDirection = SwipeDirection.Right;
                }
                else if (HasTopItems && direction == SwipeDirection.Down)
                {
                    SwipeDirection = SwipeDirection.Down;
                }
                else if (HasBottomItems && direction == SwipeDirection.Up)
                {
                    SwipeDirection = SwipeDirection.Up;
                }
                else
                {
                    return;
                }

                UpdateItems();
                ((ISwipeViewController)Element).SendSwipeStarted(new SwipeStartedEventArgs(SwipeDirection));
            }

            var offset = GetSwipeOffset(moment);

            if (IsNegativeDirection)
            {
                if (offset > 0)
                {
                    offset = 0;
                }
            }
            else
            {
                if (offset < 0)
                {
                    offset = 0;
                }
            }

            if (Math.Abs(offset) > MaximumSwipeSize)
            {
                offset = MaximumSwipeSize * (offset < 0 ? -1 : 1);
            }

            var toDragBound = NativeView.Geometry;

            if (IsHorizontalSwipe)
            {
                toDragBound.X += offset;
            }
            else
            {
                toDragBound.Y += offset;
            }
            Platform.GetRenderer(SwipeView.Content).NativeView.Geometry = toDragBound;
            ((ISwipeViewController)Element).SendSwipeChanging(new SwipeChangingEventArgs(SwipeDirection, Forms.ConvertToScaledDP(offset)));
        }