private void OnMove(GestureLayer.MomentumData data)
        {
            try
            {
                var properties = BuildProperties(true, false);
                var modifiers  = VirtualKeyModifiers.None;
                var point      = GetPoint(data.X2, data.Y2);

                _ownerEvents.RaisePointerMoved(
                    new PointerEventArgs(
                        new Windows.UI.Input.PointerPoint(
                            frameId: GetNextFrameId(),
                            timestamp: Math.Max(data.VerticalSwipeTimestamp, data.HorizontalSwipeTimestamp),
                            device: PointerDevice.For(PointerDeviceType.Touch),
                            pointerId: 0,
                            rawPosition: point,
                            position: point,
                            isInContact: properties.HasPressedButton,
                            properties: properties
                            ),
                        modifiers
                        )
                    );
            }
            catch (Exception e)
            {
                this.Log().Error("Failed to raise PointerMoved", e);
            }
        }
Beispiel #2
0
        void OnDrawerDragged(GestureLayer.MomentumData moment)
        {
            var toMove = _drawerBox.Geometry;

            toMove.Y = (moment.Y2 < 0) ? 0 : moment.Y2;

            _drawerBox.Geometry = toMove;
        }
Beispiel #3
0
        void OnContentDragStarted(GestureLayer.MomentumData moment)
        {
            _fadeInCancelTokenSource?.Cancel();
            _fadeInCancelTokenSource = null;

            if (!_isOpen)
            {
                _ = HideAsync(_drawerBox);
            }
        }
Beispiel #4
0
        bool ShouldBeOpen(GestureLayer.MomentumData data)
        {
            var momentum = IsHorizontalSwipe ? data.HorizontalMomentum : data.VerticalMomentum;

            if (Math.Abs(momentum) > MovementThreshold)
            {
                return(IsNegativeDirection ? momentum < 0 : momentum > 0);
            }

            return(Math.Abs(GetSwipeOffset(data)) > MaximumSwipeSize / 2.0);
        }
Beispiel #5
0
 void OnDrawerDragEnded(GestureLayer.MomentumData moment)
 {
     if (_drawerBox.Geometry.Y < (_mainLayout.Geometry.Height / 2))
     {
         Open();
     }
     else
     {
         Close();
     }
 }
		int GetSwipeOffset(GestureLayer.MomentumData data)
		{
			if (IsHorizontalSwipe)
			{
				return DrawerState == SwipeDrawerState.Closed ? (data.X2 - data.X1) : 
					(((IsNegativeDirection ? -1 : 1) * MaximumSwipeSize) - (data.X1 - data.X2));
			} else
			{
				return DrawerState == SwipeDrawerState.Closed ? (data.Y2 - data.Y1) : 
					(((IsNegativeDirection ? -1 : 1) * MaximumSwipeSize) - (data.Y1 - data.Y2));
			}
		}
        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);
        }
Beispiel #8
0
        void OnEnded(GestureLayer.MomentumData moment)
        {
            if (_refreshState != RefreshState.Drag)
            {
                return;
            }

            if (_shouldRefresh)
            {
                BeginRefreshing(true);
                _shouldRefresh = false;
            }
            else
            {
                ResetRefreshing();
            }
            _refreshIcon.IsPulling = false;
        }
		async void OnEnd(GestureLayer.MomentumData moment)
		{
			if (SwipeDirection == 0)
				return;

			if (ShouldBeOpen(moment))
			{
				await SwipeOpenAsync();
				if (CurrentItems.Mode == SwipeMode.Execute)
				{
					ExecuteItems(CurrentItems);
					_ = SwipeCloseAsync();
				}
			}
			else
			{
				await SwipeCloseAsync();
			}
		}
Beispiel #10
0
        void OnMoved(GestureLayer.MomentumData moment)
        {
            if (_refreshState == RefreshState.Idle && _isRefreshEnabled)
            {
                var isEdge = IsEdgeScrolling?.Invoke() ?? true;
                if (isEdge)
                {
                    _refreshState          = RefreshState.Drag;
                    _refreshIcon.IsPulling = true;
                }
            }

            if (_refreshState == RefreshState.Drag)
            {
                var dy = moment.Y2 - moment.Y1;
                if (dy < 0)
                {
                    return;
                }
                MoveLayout(dy);
            }
        }
Beispiel #11
0
        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)));
        }
 private void OnMoved(GestureLayer.MomentumData moment)
 {
 }
Beispiel #13
0
        void OnContentDragEnded(GestureLayer.MomentumData moment)
        {
            _fadeInCancelTokenSource = new CancellationTokenSource();

            _ = ShowAsync(_drawerBox, cancelltaionToken: _fadeInCancelTokenSource.Token);
        }