internal async void OnPanGestureUpdated(object sender, PanUpdatedEventArgs e) { if (Thumb == null || TrackBar == null || FillBar == null) { return; } switch (e.StatusType) { case GestureStatus.Started: await TrackBar.FadeTo(FadeEffect, AnimLength); break; case GestureStatus.Running: // Translate and ensure we don't pan beyond the wrapped user interface element bounds. var x = Math.Max(0, e.TotalX); if (x > (Width - Thumb.Width)) { x = (Width - Thumb.Width); } // Uncomment this if you want only forward dragging. // if (e.TotalX < Thumb.TranslationX) // return; Thumb.TranslationX = x; SetLayoutBounds(FillBar, new Rectangle(0, 0, x + Thumb.Width / 2, Height)); break; case GestureStatus.Completed: var posX = Thumb.TranslationX; SetLayoutBounds(FillBar, new Rectangle(0, 0, 0, Height)); // Reset translation applied during the pan await Task.WhenAll(new Task[] { TrackBar.FadeTo(1, AnimLength), Thumb.TranslateTo(0, 0, AnimLength * 2, Easing.CubicIn), }); if (posX >= (Width - Thumb.Width - 10 /* keep some margin for error*/)) { SlideCompleted?.Invoke(this, EventArgs.Empty); } break; } }