public void PanGestureRecognizer_PanUpdated(System.Object sender, Xamarin.Forms.PanUpdatedEventArgs e) { // Handle the pan switch (e.StatusType) { case GestureStatus.Running: // Translate and ensure we don't y + e.TotalY pan beyond the wrapped user interface element bounds. var translateY = Math.Max(Math.Min(0, y + e.TotalY), -Math.Abs((Height * .25) - Height)); BottomSheet.TranslateTo(BottomSheet.X, translateY, 20); break; case GestureStatus.Completed: // Store the translation applied during the pan y = BottomSheet.TranslationY; // At the end of the event - snap to the closest location var finalTranslation = Math.Max(Math.Min(0, -1000), -Math.Abs(GetClosestLockState(e.TotalY + y))); // Depending on Swipe Up or Down - change the snapping animation if (IsSwipeUp(e)) { BottomSheet.TranslateTo(BottomSheet.X, finalTranslation, 250, Easing.SpringIn); } else { BottomSheet.TranslateTo(BottomSheet.X, finalTranslation, 250, Easing.SpringOut); } // Dismiss the keyboard after a transition y = BottomSheet.TranslationY; break; } }
async void PanGestureRecognizer_PanUpdated(System.Object sender, Xamarin.Forms.PanUpdatedEventArgs e) { if (e.StatusType == GestureStatus.Running) { isBackdropTapEnabled = false; lastPanY = e.TotalY; Debug.WriteLine($"Running: {e.TotalY}"); if (e.TotalY > 0) { BottomToolbar.TranslationY = openY + e.TotalY; } } else if (e.StatusType == GestureStatus.Completed) { //Debug.WriteLine($"Completed: {e.TotalY}"); if (lastPanY < 110) { await OpenDrawer(); } else { await CloseDrawer(); } isBackdropTapEnabled = true; } }
async void PanGestureRecognizer_PanUpdated(System.Object sender, Xamarin.Forms.PanUpdatedEventArgs e) { switch (e.StatusType) { case GestureStatus.Running: //Console.WriteLine(e.TotalY); if (e.TotalY / 3 + savedTranslationY > 0) { cakeView.TranslationY = e.TotalY / 3 + savedTranslationY; lastTranslationY = cakeView.TranslationY; //Math.Max(Math.Min(0, cakeView.Y + e.TotalY),-Math.Abs(Content.Height - page.Height)); } break; case GestureStatus.Completed: savedTranslationY = lastTranslationY; if (savedTranslationY <= GetHeight * 0.14) { await cakeView.TranslateTo(0, 0, 300); savedTranslationY = cakeView.TranslationY = 0; } else { await Navigation.PopPopupAsync(); } //Console.WriteLine("Completed"); break; } }
void Handle_PanUpdated(object sender, Xamarin.Forms.PanUpdatedEventArgs e) { if (e.StatusType == GestureStatus.Completed) { if (xTransition > 50) { if (profileViewModel.SelectedIndex != 0) { profileViewModel.SelectedIndex -= 1; profileViewModel.HandleSwipe(); } } else if (xTransition < -50) { if (profileViewModel.SelectedIndex < 2) { profileViewModel.SelectedIndex += 1; profileViewModel.HandleSwipe(); } } } else { xTransition = e.TotalX; } }
private async void Handle_PanUpdated(object sender, Xamarin.Forms.PanUpdatedEventArgs e) { switch (e.StatusType) { case GestureStatus.Started: panX = 0; break; case GestureStatus.Running: panX = e.TotalX; break; case GestureStatus.Completed: if (panX > 0) { await controller.ChangePageBackwards(); } else { await controller.ChangePageForwards(); } break; } }
void PanGestureRecognizer_PanUpdated(System.Object sender, Xamarin.Forms.PanUpdatedEventArgs e) { System.Diagnostics.Debug.WriteLine($"Status: {e.StatusType}"); switch (e.StatusType) { case GestureStatus.Started: case GestureStatus.Running: System.Diagnostics.Debug.WriteLine($"X: {e.TotalX} - Y: {e.TotalY}"); Video.TranslationX = e.TotalX; Video.TranslationY = e.TotalY; break; case GestureStatus.Completed: var pageWidth = Width; var pageHeight = Height; var positionX = Video.X + Video.TranslationX; var positionY = Video.Y + Video.TranslationY; var halfWidthVideo = Video.WidthRequest / 2; var halfHeightVideo = Video.HeightRequest / 2; if (halfWidthVideo + positionX > pageWidth / 2) { // move video to the right if (halfHeightVideo + positionY > pageHeight / 2) { // move video to the bottom AbsoluteLayout.SetLayoutBounds(Video, GetRightBottomPosition()); } else { // move video to the top AbsoluteLayout.SetLayoutBounds(Video, GetRightTopPosition()); } } else { // move video to the left if (halfHeightVideo + positionY > pageHeight / 2) { // move video to the bottom AbsoluteLayout.SetLayoutBounds(Video, GetLeftBottomPosition()); } else { // move video to the top AbsoluteLayout.SetLayoutBounds(Video, GetLeftTopPosition()); } } System.Diagnostics.Debug.WriteLine($"Page width: {pageWidth} - Page height: {pageHeight}"); Video.TranslationX = 0; Video.TranslationY = 0; break; } }
void OnPanUpdated (object sender, PanUpdatedEventArgs e) { switch (e.StatusType) { case GestureStatus.Running: // Translate and ensure we don't pan beyond the wrapped user interface element bounds. Content.TranslationX = Math.Max (Math.Min (0, x + e.TotalX), -Math.Abs (Content.Width - App.ScreenWidth)); Content.TranslationY = Math.Max (Math.Min (0, y + e.TotalY), -Math.Abs (Content.Height - App.ScreenHeight)); break; case GestureStatus.Completed: // Store the translation applied during the pan x = Content.TranslationX; y = Content.TranslationY; break; } }
private void OnPanUpdated(object sender, PanUpdatedEventArgs e) { switch (e.StatusType) { case GestureStatus.Running: // Translate and ensure we don't pan beyond the wrapped user interface element bounds. // Math.Max(Math.Min(0, x + e.TotalX), -Math.Abs(Content.Width - _device.ScreenWidth)); this.TranslationX = e.TotalX; this.TranslationY = e.TotalY; // Math.Max(Math.Min(0, y + e.TotalY), -Math.Abs(Content.Height - _device.ScreenHeight)); break; case GestureStatus.Completed: // Store the translation applied during the pan x = Content.TranslationX; y = Content.TranslationY; //this.Content.Layout(new Rectangle(x, y, this.Width, this.Height)); break; } }
void PanGestureRecognizer_PanUpdated(System.Object sender, Xamarin.Forms.PanUpdatedEventArgs e) { //myLayout.AnchorX = 0.5; //myLayout.AnchorY = 0.3; switch (e.StatusType) { case GestureStatus.Started: View view = (View)sender; x = e.TotalX; y = e.TotalY; break; case GestureStatus.Running: // Translate and ensure we don't pan beyond the wrapped user interface element bounds. x = e.TotalX; y = e.TotalY; var rad = Math.Atan2(y, x); // In radians var deg = rad * (180 / Math.PI); testLayout.InitialStartPositionAngle = deg; //Console.WriteLine("running" + testLayout.Rotation); //myLayout.RotateYTo(y, 1000, Easing.Linear); break; case GestureStatus.Completed: //Console.WriteLine("Completed" + myLayout.Rotation); // Store the translation applied during the pan //x = 0; //y = 0; //myLayout.RotateTo(0); //myLayout.Rotation = 0; break; } }
private void RightButtonPanGesture(object sender, PanUpdatedEventArgs e) { var sliderPathWidth = _viewSize.Width - (PADDING * 2.0); var numberOfSteps = (this.MaxValue - this.MinValue) / this.Step; var pixelsPerStep = sliderPathWidth / numberOfSteps; switch (e.StatusType) { case GestureStatus.Started: _rightButtonPanGesturePosX = _rightButton.X; break; case GestureStatus.Running: var rightButtonX = _rightButtonPanGesturePosX + e.TotalX; var newRightValue = ((rightButtonX - BUTTON_START_X) / pixelsPerStep) * this.Step; newRightValue = AdjustRightValue(newRightValue); if(newRightValue != this.RightValue) { this.RightValue = newRightValue; } break; case GestureStatus.Completed: _rightButtonPanGesturePosX = 0.0; ChangeValueFinished(); break; } }
public MainPage () { InitializeComponent (); BindingContext = new { SvgAssembly = typeof(App).GetTypeInfo ().Assembly, CanvasHeight = App.CanvasHeight }; NavigationPage.SetHasNavigationBar(this, false); //TapGestureRecognizer crossTapGestureRecognizer = new TapGestureRecognizer(); TapGestureRecognizer canvasTapGestureRecognizer = new TapGestureRecognizer(); PanGestureRecognizer canvasPanGestureRecognizer = new PanGestureRecognizer(); // crossTapGestureRecognizer.Tapped += (object sender, EventArgs e) => { // ChangeTempWindow.Hide(); // ChangeGeoWindow.Hide(); // }; ArrowsInitialize (); ChangeTempWindow.Initialize (); //ChangeTempWindowCross.GestureRecognizers.Add (crossTapGestureRecognizer); ChangeGeoWindow.Initialize (); //ChangeGeoWindowCross.GestureRecognizers.Add (crossTapGestureRecognizer); ClothWindow.Initialize (true); HeadClickZone.GestureRecognizers.Add (canvasTapGestureRecognizer); BodyClickZone.GestureRecognizers.Add (canvasTapGestureRecognizer); PantsClickZone.GestureRecognizers.Add (canvasTapGestureRecognizer); ShoesClickZone.GestureRecognizers.Add (canvasTapGestureRecognizer); HeadClickZone.GestureRecognizers.Add (canvasPanGestureRecognizer); BodyClickZone.GestureRecognizers.Add (canvasPanGestureRecognizer); PantsClickZone.GestureRecognizers.Add (canvasPanGestureRecognizer); ShoesClickZone.GestureRecognizers.Add (canvasPanGestureRecognizer); ColorPickerWindow.Initialize (false, true); AllColorsButton.Clicked += (object sender, EventArgs e) => { ColorPickerWindow.Show(); }; canvasTapGestureRecognizer.Tapped += (object sender, EventArgs e) => { ClothType type = ClothType.Head; if(sender.Equals(HeadClickZone)) type = ClothType.Head; if(sender.Equals(BodyClickZone)) type = ClothType.Body; if(sender.Equals(PantsClickZone)) type = ClothType.Pants; if(sender.Equals(ShoesClickZone)) type = ClothType.Shoes; if(DBClothes(type).Count == 0) return; if(type == ClothType.Head && DBHeads[CurrentHead].Id == 142) return; if(type == ClothType.Pants && DBBodies[CurrentBody].IsDress) return; ClothWindow.Type = type; ClothWindowSvgContainer.Content = new CWCloth { SvgPath = "ClothesAndWeather.Images.ClothesDB." + DBClothes(type) [CurrentCloth(type)].ImagePreview, Color = ((CWCloth)ClothView(type).Content).Color, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, WidthRequest = 120, HeightRequest = 120, Aspect = Aspect.AspectFit }; ClothTitleLabel.Text = DBClothes(type) [CurrentCloth(type)].Name; ClothDescLabel.Text = DBClothes(type) [CurrentCloth(type)].Description; List<ClothExample> examples = Sex == Sex.Male ? DBClothes(type) [CurrentCloth(type)].ManClothes : DBClothes(type) [CurrentCloth(type)].WomanClothes; if(examples == null) examples = new List<ClothExample>(); ClothExamples.Children.Clear(); ClothExamples.Children.Add(new Label { Text = "Похожие вещи в магазине:", FontSize = 12 }); StackLayout line = new StackLayout(); for(var i = 0; i < examples.Count; i++) { if(i % 2 == 0) line = new StackLayout { Orientation = StackOrientation.Horizontal, Spacing = 25, HorizontalOptions = LayoutOptions.Center }; var frame = new CWClothExample(); frame.Content = new Image { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Aspect = Aspect.AspectFit, Source = ImageSource.FromUri(new Uri("http:" + examples[i].Image)) }; var recognizer = new TapGestureRecognizer(); string link = examples[i].Link; recognizer.Tapped += (object sender1, EventArgs e1) => { App.IOSAppDelegate.OpenUrlInBrowser(Utils.AdmitadLink(link)); }; frame.GestureRecognizers.Add(recognizer); line.Children.Add(frame); if(i == examples.Count - 1 && i % 2 == 0) { line.WidthRequest = (frame.WidthRequest + frame.Padding.Left + frame.Padding.Right) * 2 + line.Spacing; frame.HorizontalOptions = LayoutOptions.Start; } if(i % 2 == 1 || i == examples.Count - 1) ClothExamples.Children.Add(line); } ClothWindow.Show(); }; PanUpdatedEventArgs lastPan = new PanUpdatedEventArgs(GestureStatus.Completed, 0, 0, 0); canvasPanGestureRecognizer.PanUpdated += (object sender, PanUpdatedEventArgs e) => { ClothType type = ClothType.Head; if(sender.Equals(HeadClickZone)) type = ClothType.Head; if(sender.Equals(BodyClickZone)) type = ClothType.Body; if(sender.Equals(PantsClickZone)) type = ClothType.Pants; if(sender.Equals(ShoesClickZone)) type = ClothType.Shoes; if(e.StatusType == GestureStatus.Completed) { double x = lastPan.TotalX; double y = lastPan.TotalY; System.Diagnostics.Debug.WriteLine(x + " " + y); if(Math.Abs(y) <= 25 && Math.Abs(x) >= 40) { CallArrow(Arrow(type, (int)(x / Math.Abs(x)))); } } lastPan = e; }; Action<object, EventArgs> changePreviewColor = (object sender, EventArgs e) => { ClothWindowSvgContainer.Content = new CWCloth { SvgPath = ((CWCloth)ClothWindowSvgContainer.Content).SvgPath, Color = ((Button)sender).BackgroundColor, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, WidthRequest = 120, HeightRequest = 120, Aspect = Aspect.AspectFit }; }; BlackColorButton.Clicked += (object sender, EventArgs e) => { changePreviewColor.Invoke(sender, e); }; WhiteColorButton.Clicked += (object sender, EventArgs e) => { changePreviewColor.Invoke(sender, e); }; for (int i = 0; i < ColorsGrid.Children.Count; i++) { ((Button)ColorsGrid.Children[i]).Clicked += (object sender, EventArgs e) => { changePreviewColor.Invoke(sender, e); ColorPickerWindow.Hide(); }; } ColorReadyButton.Clicked += (object sender, EventArgs e) => { SwitchClothColor((ClothType)ClothWindow.Type, ((CWCloth)ClothWindowSvgContainer.Content).Color); ClothWindow.Hide(); }; // ClothesOnlineButton.Clicked += (object sender, EventArgs e) => { // Cloth cloth = DBClothes((ClothType)ClothWindow.Type)[CurrentCloth((ClothType)ClothWindow.Type)]; // App.IOSAppDelegate.OpenUrlInBrowser(cloth.GetLamodaLink(Sex)); // }; #region BottomMenu TapGestureRecognizer menuTapGestureRecognizer = new TapGestureRecognizer(); TapGestureRecognizer menu3TapGestureRecognizer = new TapGestureRecognizer(); switch (Sex) { case Sex.Male: ((SvgImage)menu3.Content).SvgPath = "ClothesAndWeather.Images.menu3m.svg"; break; case Sex.Female: ((SvgImage)menu3.Content).SvgPath = "ClothesAndWeather.Images.menu3f.svg"; break; } menu1.GestureRecognizers.Add (menuTapGestureRecognizer); TempLabel.GestureRecognizers.Add(menuTapGestureRecognizer); WeatherConditionImage.GestureRecognizers.Add(menuTapGestureRecognizer); menu4.GestureRecognizers.Add (menuTapGestureRecognizer); CityAndDT.GestureRecognizers.Add (menuTapGestureRecognizer); menuTapGestureRecognizer.Tapped += (object sender, EventArgs e) => { //SvgImage btn = (SvgImage)sender; var btn = sender; if(btn.Equals(menu1) || btn.Equals(TempLabel) || btn.Equals(WeatherConditionImage)) { ChangeTempWindow.Show(); } else if(btn.Equals(menu4) || btn.Equals(CityAndDT)) { ChangeGeoWindow.Show(); } }; menu3.GestureRecognizers.Add (menu3TapGestureRecognizer); menu3TapGestureRecognizer.Tapped += (object sender, EventArgs e) => { string newpath = ""; switch(Sex) { case Sex.Male: newpath = "ClothesAndWeather.Images.menu3f.svg"; App.SetSex(Sex.Female); break; case Sex.Female: newpath = "ClothesAndWeather.Images.menu3m.svg"; App.SetSex(Sex.Male); break; } menu3.Content = new SvgImage { SvgPath = newpath, SvgAssembly = typeof(App).GetTypeInfo().Assembly }; RefreshFilters(); }; PlacePicker.Unfocused += async (object sender, FocusEventArgs e) => { switch(PlacePicker.SelectedIndex) { case 0: App.SetPlace(Place.Walk); await Navigation.PushModalAsync(new SelectWalkTimePage(false), false); break; case 1: App.SetPlace(Place.Business); RefreshFilters(); break; case 2: App.SetPlace(Place.Formal); RefreshFilters(); break; case 3: App.SetPlace(Place.Celebration); RefreshFilters(); break; case 4: App.SetPlace(Place.Sport); RefreshFilters(); break; } }; #endregion #region TempAndCityWindows SetUserTemp.Clicked += (object sender, EventArgs e) => { if(String.IsNullOrEmpty(UserTemp.Text) || UserWeatherTagPicker.SelectedIndex == -1) { if(String.IsNullOrEmpty(UserTemp.Text)) HighlightView(UserTemp); if(UserWeatherTagPicker.SelectedIndex == -1) HighlightView(UserWeatherTagPicker); return; } try { Temperature = Convert.ToInt32(UserTemp.Text); } catch(Exception ex) { HighlightView(UserTemp); return; } if(Temperature < -50 || Temperature > 40) { HighlightView(UserTemp); return; } UserTemp.Unfocus(); TempLabel.Text = Temperature + " °C"; WeatherTag = Utils.PickerValueToTag (UserWeatherTagPicker.SelectedIndex); WeatherConditionImage.Content = new SvgImage { SvgPath = "ClothesAndWeather.Images.Tags." + WeatherTag + ".svg", SvgAssembly = typeof(App).GetTypeInfo ().Assembly }; RefreshFilters(); ChangeTempWindow.Hide(); }; SetAutoTemp.Clicked += (object sender, EventArgs e) => { GetOpenWeatherData (() => { RefreshFilters (); ChangeTempWindow.Hide(); }, () => { }, true); }; SetUserCity.Clicked += (object sender, EventArgs e) => { if(String.IsNullOrEmpty(UserCity.Text)) { HighlightView(UserCity); return; } UserCity.Unfocus(); string oldCity = City; City = UserCity.Text; GetOpenWeatherData (() => { CityLabel.Text = City; RefreshFilters (); ChangeGeoWindow.Hide(); }, () => { HighlightView(UserCity); City = oldCity; }, false); GetTimeByCity(() => {}); }; SetAutoCity.Clicked += (object sender, EventArgs e) => { GetGoogleCityName (); GetOpenWeatherData (() => { TimeZone = null; DTSwitchOnce(); RefreshFilters(); ChangeGeoWindow.Hide(); }, () => { }, true); }; #endregion #region Arrows TapGestureRecognizer clothesArrowsTapGestureRecognizer = new TapGestureRecognizer(); HeadLeft.GestureRecognizers.Add(clothesArrowsTapGestureRecognizer); HeadRight.GestureRecognizers.Add(clothesArrowsTapGestureRecognizer); BodyLeft.GestureRecognizers.Add(clothesArrowsTapGestureRecognizer); BodyRight.GestureRecognizers.Add(clothesArrowsTapGestureRecognizer); PantsLeft.GestureRecognizers.Add(clothesArrowsTapGestureRecognizer); PantsRight.GestureRecognizers.Add(clothesArrowsTapGestureRecognizer); ShoesLeft.GestureRecognizers.Add(clothesArrowsTapGestureRecognizer); ShoesRight.GestureRecognizers.Add(clothesArrowsTapGestureRecognizer); clothesArrowsTapGestureRecognizer.Tapped += (object sender, EventArgs e) => { CWArrow btn = (CWArrow)sender; CallArrow(btn); }; #endregion EnableDTSwitch (); GetGoogleCityName (); GetOpenWeatherData (() => { RefreshFilters (); }, () => { }, true); }
void PanGestureRecognizer_PanUpdated(System.Object sender, Xamarin.Forms.PanUpdatedEventArgs e) { lbl.GestureRecognizers.Clear(); stk.Children.Remove(lbl); garbage.Add(lbl); }
public void PanImage(PanUpdatedEventArgs e) { if (e.StatusType == GestureStatus.Completed) { mX = CurrentXOffset; mY = CurrentYOffset; } else if (e.StatusType == GestureStatus.Running) { CurrentXOffset = (e.TotalX * mRatioPan) + mX; CurrentYOffset = (e.TotalY * mRatioPan) + mY; ReloadImage (); } }
void OnPanUpdated (object sender, PanUpdatedEventArgs e) { if (e.StatusType == GestureStatus.Started) { startX = relativeLayoutTest.TranslationX; startY = relativeLayoutTest.TranslationY; } if (e.StatusType == GestureStatus.Running) { relativeLayoutTest.TranslationX = e.TotalX + startX; relativeLayoutTest.TranslationY = e.TotalY + startY; if (((int) relativeLayoutTest.TranslationX) > 0) { relativeLayoutTest.TranslationX = 0; } else if ((((int) relativeLayoutTest.TranslationX) + (relativeLayoutTest.Width * relativeLayoutTest.Scale)) < App.coreView.Width) { relativeLayoutTest.TranslationX = (App.coreView.Width - (relativeLayoutTest.Width * relativeLayoutTest.Scale)); } } }
private void OnGrapPage(object sender, PanUpdatedEventArgs e) { if (e.StatusType == GestureStatus.Running) { dragX = e.TotalX; dragY = e.TotalY; } else if (e.StatusType == GestureStatus.Completed) { if (Math.Abs(dragX) < 72) return; var time = (DateTime.Now - lastDragTime); if (time.TotalMilliseconds > 500)// too slow { lastDragTime = DateTime.Now; return; } if (isNoticed || curQuiz == null || curQuiz.state != Quiz.QuizState.Ansing) { lastDragTime.AddMilliseconds(-1000); isNoticed = false; RefreshQuiz(); } else { CrossVibrate.Current.Vibration(); isNoticed = true; } } }
void OnPanUpdated(object sender, PanUpdatedEventArgs e) { System.Diagnostics.Debug.WriteLine(e.TotalX + " " + e.TotalX); }
/* * Important code lies below */ void PanGestureRecognizer_PanUpdated(System.Object sender, Xamarin.Forms.PanUpdatedEventArgs e) { // Handle the pan switch (e.StatusType) { case GestureStatus.Running: // Translate and ensure we don't y + e.TotalY pan beyond the wrapped user interface element bounds. var translateY = Math.Max(Math.Min(0, y + e.TotalY), -Math.Abs((Height * .25) - Height)); //bottomSheet.TranslateTo(bottomSheet.X, -1*(currentPostionY+(-1*translateY)),20); //up working good if (e.TotalY >= 5 || e.TotalY <= -5 && !isTurnY) { isTurnY = true; } if (isTurnY) { if (e.TotalY <= valueY) { up = true; } if (e.TotalY >= valueY) { down = true; } } if (up) { if (Device.RuntimePlatform == Device.Android) { if (yFullPosition < (currentPostionY + (-1 * e.TotalY))) { bottomSheet.TranslateTo(bottomSheet.X, -yFullPosition); } else { bottomSheet.TranslateTo(bottomSheet.X, -1 * (currentPostionY + (-1 * e.TotalY))); } } else { if (yFullPosition < (currentPostionY + (-1 * e.TotalY))) { bottomSheet.TranslateTo(bottomSheet.X, -yFullPosition, 20); } else { bottomSheet.TranslateTo(bottomSheet.X, -1 * (currentPostionY + (-1 * e.TotalY)), 20); } } } else if (down) { if (Device.RuntimePlatform == Device.Android) { if (yZeroPosition > currentPostionY - e.TotalY) { bottomSheet.TranslateTo(bottomSheet.X, -yZeroPosition); } else { bottomSheet.TranslateTo(bottomSheet.X, -(currentPostionY - (e.TotalY))); } } else { if (yZeroPosition > currentPostionY - e.TotalY) { bottomSheet.TranslateTo(bottomSheet.X, -yZeroPosition, 20); } else { bottomSheet.TranslateTo(bottomSheet.X, -(currentPostionY - (e.TotalY)), 20); } } } break; case GestureStatus.Completed: // Store the translation applied during the pan valueY = e.TotalY; y = bottomSheet.TranslationY; //at the end of the event - snap to the closest location //var finalTranslation = Math.Max(Math.Min(0, -1000), -Math.Abs(getClosestLockState(e.TotalY + y))); //depending on Swipe Up or Down - change the snapping animation if (up) { //swipe up happened if (currentPsotion == 1) { bottomSheet.TranslateTo(bottomSheet.X, -yFullPosition); currentPsotion = 2; currentPostionY = yFullPosition; bottomsheetListView.HeightRequest = yFullPosition; bottomsheetListView.HeightRequest = yFullPosition; //bottomSheet.TranslateTo(bottomSheet.X, finalTranslation, 250, Easing.SpringIn); } else if (currentPsotion == 0) { double currentY = (-1) * y; double differentBetweenHalfAndCurrent = Math.Abs(currentY - yHalfPosition); double differentBetweenFullAndCurrent = Math.Abs(currentY - yFullPosition); //check which is close snap point and move to the closest snap point if (differentBetweenHalfAndCurrent < differentBetweenFullAndCurrent) { //yHalfPosition is the closest one bottomSheet.TranslateTo(bottomSheet.X, -yHalfPosition); currentPsotion = 1; currentPostionY = yHalfPosition; bottomsheetListView.HeightRequest = yHalfPosition; } else { bottomSheet.TranslateTo(bottomSheet.X, -yFullPosition); currentPsotion = 2; currentPostionY = yFullPosition; bottomsheetListView.HeightRequest = yFullPosition; } } } if (down) { //swipe down happened if (currentPsotion == 1) { bottomSheet.TranslateTo(bottomSheet.X, -yZeroPosition); currentPsotion = 0; currentPostionY = yZeroPosition; } else if (currentPsotion == 2) { double currentY = (-1) * y; double differentBetweenHalfAndCurrent = Math.Abs(currentY - yHalfPosition); double differentBetweenZeroAndCurrent = Math.Abs(currentY - yZeroPosition); //check which is close snap point and move to the closest snap point if (differentBetweenHalfAndCurrent < differentBetweenZeroAndCurrent) { //yHalfPosition is the closest one bottomSheet.TranslateTo(bottomSheet.X, -yHalfPosition); currentPsotion = 1; currentPostionY = yHalfPosition; bottomsheetListView.HeightRequest = yHalfPosition; } else { bottomSheet.TranslateTo(bottomSheet.X, -yZeroPosition); currentPsotion = 0; currentPostionY = yZeroPosition; } } //bottomSheet.TranslateTo(bottomSheet.X, finalTranslation, 250, Easing.SpringOut); } //dismiss the keyboard after a transition //SearchBox.Unfocus(); y = bottomSheet.TranslationY; up = false; down = false; break; } }
private void RightButtonPanGesture(object sender, PanUpdatedEventArgs e) { switch (e.StatusType) { case GestureStatus.Started: _rightButtonPanGesturePosX = _rightButton.X; break; case GestureStatus.Running: if(Device.OS == TargetPlatform.Android) { _rightButtonPanGesturePosX = _rightButton.X; } this.RightValue = AdjustRightValue(((_rightButtonPanGesturePosX + e.TotalX - BUTTON_START_X) / GetPixelsPerStep()) * this.Step); break; case GestureStatus.Completed: _rightButtonPanGesturePosX = 0.0; ChangeValueFinished(); break; } }