Skip to content

Commit

Permalink
https://github.com/AndreiMisiukevich/CardView/issues/52
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiMisiukevich committed Jul 15, 2018
1 parent 8cc29b7 commit 285973b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion PanCardView.Droid/CardsViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ protected override void OnElementChanged(ElementChangedEventArgs<CardsView> e)
}

private bool SetIsTouchHandled(float xDelta, float yDelta)
=> IsTouchHandled = Abs(xDelta) > Abs(yDelta);
{
var xDeltaAbs = Abs(xDelta);
var yDeltaAbs = Abs(yDelta);
return IsTouchHandled = xDeltaAbs > yDeltaAbs &&
xDeltaAbs > Element.MoveThresholdDistance;
}

private void HandleDownUpEvents(MotionEvent ev)
{
Expand Down
12 changes: 12 additions & 0 deletions PanCardView/CardsView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public class CardsView : AbsoluteLayout

public static readonly BindableProperty SwipeThresholdDistanceProperty = BindableProperty.Create(nameof(SwipeThresholdDistance), typeof(double), typeof(CardsView), 17.0);

public static readonly BindableProperty MoveThresholdDistanceProperty = BindableProperty.Create(nameof(MoveThresholdDistance), typeof(double), typeof(CardsView), 0.0);

public static readonly BindableProperty SwipeThresholdTimeProperty = BindableProperty.Create(nameof(SwipeThresholdTime), typeof(TimeSpan), typeof(CardsView), TimeSpan.FromMilliseconds(Device.RuntimePlatform == Device.Android ? 100 : 60));

public static readonly BindableProperty PanStartedCommandProperty = BindableProperty.Create(nameof(PanStartedCommand), typeof(ICommand), typeof(CardsView), null);
Expand Down Expand Up @@ -337,6 +339,16 @@ public double SwipeThresholdDistance
set => SetValue(SwipeThresholdDistanceProperty, value);
}

/// <summary>
/// Only for Android
/// </summary>
/// <value>The move threshold distance.</value>
public double MoveThresholdDistance
{
get => (double)GetValue(MoveThresholdDistanceProperty);
set => SetValue(MoveThresholdDistanceProperty, value);
}

public TimeSpan SwipeThresholdTime
{
get => (TimeSpan)GetValue(SwipeThresholdTimeProperty);
Expand Down

0 comments on commit 285973b

Please sign in to comment.