Skip to content

Commit

Permalink
Merge pull request #70 from Jamesmallon1/patch-1
Browse files Browse the repository at this point in the history
Update GestureFrameRenderer.cs
  • Loading branch information
robinmanuelthiel authored Feb 27, 2019
2 parents 7cd38d7 + 3ee8c40 commit 75125bd
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions Flex.UWP/CutomRenderers/GestureFrameRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE

}

protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Frame> e)
{
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Frame> e)
{
base.OnElementChanged(e);

if (e.OldElement == null)
{
FixFormsBackgroundColor(e.NewElement);

if (!e.NewElement.GestureRecognizers.Any())
return;

if (!e.NewElement.GestureRecognizers.Any(x => x.GetType() == typeof(TouchGestureRecognizer)))
if (!e.NewElement.GestureRecognizers.Any())
return;

if (!e.NewElement.GestureRecognizers.Any(x => x.GetType() == typeof(TouchGestureRecognizer)))
return;

Control.PointerPressed += Control_PointerPressed;
Expand All @@ -54,7 +54,7 @@ protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.F
// Fix Xamarin.Forms Frame Bugs on UWP
Control.SizeChanged += (s, a) => FixFormsBackgroundColor(Element);
Control.CornerRadius = new Windows.UI.Xaml.CornerRadius(Element.CornerRadius);
}
}
}

/// <summary>
Expand Down Expand Up @@ -84,6 +84,9 @@ private void FixFormsBackgroundColor(Xamarin.Forms.Frame frame)

private void Control_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
{
if(Element == null)
return;

pressed = true;

foreach (var recognizer in Element.GestureRecognizers.Where(x => x.GetType() == typeof(TouchGestureRecognizer)))
Expand All @@ -97,6 +100,9 @@ private void Control_PointerPressed(object sender, Windows.UI.Xaml.Input.Pointer

private void Control_PointerReleased(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
{
if(Element == null)
return;

foreach (var recognizer in Element.GestureRecognizers.Where(x => x.GetType() == typeof(TouchGestureRecognizer)))
{
if (recognizer is TouchGestureRecognizer touchGestureRecognizer)
Expand Down

0 comments on commit 75125bd

Please sign in to comment.