/// <summary> /// Animate toggle /// </summary> private void OnIsToggledChanged(bool toggled) { AnimationExtensions.AbortAnimation(this, _animationName); double start = _toggledAnimationProcessWithoutEasing; double end = 1; if (toggled == false) { start = _toggledAnimationProcessWithoutEasing; end = 0; } Animation anim = new Animation(d => { if (toggled) { _toggledAnimationProcess = AnimationEasing.Ease(d); } else { _toggledAnimationProcess = 1 - AnimationEasing.Ease(1 - d); } _toggledAnimationProcessWithoutEasing = d; _skiaCanvas.InvalidateSurface(); }, start, end); anim.Commit(this, _animationName, 64, (uint)AnimationDuration, Easing.Linear); }
internal void AbortAnimations(TouchEff sender) { _animationTokenSource?.Cancel(); var control = sender.Control; if (control == null) { return; } ViewExtensions.CancelAnimations(control); AnimationExtensions.AbortAnimation(control, ChangeBackgroundColorAnimationName); }
private void IntroPage_Closed(object sender, EventArgs e) { mInfo.IsVisible = true; var animation = new Animation(v => mAddCareDayButton.Scale = v, 1, 1.2); animation.Commit(mAddCareDayButton, "SimpleAnimation", 16, 1000, Easing.Linear, (v, c) => mAddCareDayButton.Scale = 1, () => true); var aTimer = new System.Timers.Timer(10000); aTimer.Elapsed += (s, ev) => { Device.BeginInvokeOnMainThread(() => { var animation1 = new Animation(v => mInfo.Scale = v, 1, 0.0); animation1.Commit(this, "SimpleAnimation1", 16, 1000, Easing.Linear, (v, c) => { mInfo.Scale = 0; mInfo.IsVisible = false; }, () => false); AnimationExtensions.AbortAnimation(mAddCareDayButton, "SimpleAnimation"); }); }; aTimer.Enabled = true; }
/// <summary> /// Animate toggle /// </summary> private void OnIsToggledChanged(bool toggled, bool isEllipseAnimationEnabled = true) { if (_ignoreIsToggledEventHandling) { return; } _ignoreIsToggledEventHandling = true; IsToggled = toggled; _ignoreIsToggledEventHandling = false; AnimationExtensions.AbortAnimation(this, _animationName); if (IsToggled) { HandleGroupIsToggledChanged(IsToggled); } double start = _toggledAnimationProcessWithoutEasing; double end = 1; if (toggled == false) { start = _toggledAnimationProcessWithoutEasing; end = 0; } Animation anim = new Animation(d => { _toggledAnimationProcess = AnimationEasing.Ease(d); _toggledAnimationProcessWithoutEasing = d; if (isEllipseAnimationEnabled) { _ellipseAnimationProcess = d; } _skiaCanvas.InvalidateSurface(); }, start, end); anim.Commit(this, _animationName, 64, (uint)AnimationDuration, Easing.Linear); }
/// <summary> /// Do toggle animation /// </summary> protected void DoToggleAnimation(bool isToggled, Action <double, bool> finished = null) { AnimationExtensions.AbortAnimation(this, _toggledAnimationName); double start = 0; double to = 0; if (isToggled) { start = 0; to = 1; } else { start = 1; to = 0; } new Animation((d) => { _toggledAnimationProcess = d; _skiaCanvas.InvalidateSurface(); }, start, to).Commit(this, _toggledAnimationName, 64, (uint)PressedAnimationDuration, PressedAnimationEasing, finished); }
public override void CancelAnimation() { AnimationExtensions.AbortAnimation(Target, "Jump"); }
public override void CancelAnimation() { AnimationExtensions.AbortAnimation(Target, "TurnstileIn"); }
/// <summary> /// Update headers and navigation bar translation Y by scroll /// </summary> private static void HandleScrolling(HeaderLayout headerLayout, ContentPage contentPage, NavigationPage navigationPage, double oldScrollY, double newScrollY) { // Save previous scroll Y if (headerLayout != null) { headerLayout.ScrollY = newScrollY; } TryGetNavigationBarProperties(contentPage, navigationPage, out double navigationBarHeight, out double navigationBarY, out bool isNavigationBarFloating, out bool isNavigationBarScrollable); // Scroll delta double delta = Math.Max(0, newScrollY) - Math.Max(0, oldScrollY); // Update navigation bar translation when it should scroll out smoothly or not if (navigationPage != null && contentPage != null && (NavigationBar.GetVisibility(contentPage) == NavigationBarVisibility.Scroll || NavigationBar.GetVisibility(contentPage) == NavigationBarVisibility.SmoothScroll)) { View navigationBar = navigationPage.GetNavigationBar(); // Hide navigation bar smoothly if (NavigationBar.GetVisibility(contentPage) == NavigationBarVisibility.SmoothScroll && navigationBar != null) { // If scrolled enought speed do smooth navigation bar hiding with animation if (Math.Abs(delta) > 5) { string showScrollBarAnimationName = "showScrollBarAnimation"; string hideScrollBarAnimationName = "hideScrollBarAnimation"; double start = navigationBar.TranslationY; double target = 0; string actualAnimationName; if (delta < 0) { target = 0; actualAnimationName = showScrollBarAnimationName; } else { target = -navigationBarHeight + RootPage.Instance.SafeAreaInsest.Top; actualAnimationName = hideScrollBarAnimationName; } if (target != navigationBar.TranslationY && AnimationExtensions.AnimationIsRunning(navigationBar, actualAnimationName) == false) { AnimationExtensions.AbortAnimation(navigationBar, showScrollBarAnimationName); AnimationExtensions.AbortAnimation(navigationBar, hideScrollBarAnimationName); new Animation(d => { // Animate NavigastionBar TranslationY navigationBar.TranslationY = start + (target - start) * d; // Get NavigationBar properties during animation because they can change TryGetNavigationBarProperties(contentPage, navigationPage, out navigationBarHeight, out navigationBarY, out isNavigationBarFloating, out isNavigationBarScrollable); // Update headers transaltion because navigation bar translation is animated headerLayout?.UpdateHeadersTranslationY(headerLayout.ScrollY, navigationBarHeight, navigationBarY, isNavigationBarFloating, isNavigationBarScrollable); }, 0, 1).Commit(navigationBar, actualAnimationName, 64, 250); } else { headerLayout?.UpdateHeadersTranslationY(newScrollY, navigationBarHeight, navigationBar.TranslationY, isNavigationBarFloating, isNavigationBarScrollable); } } // If not scrolled enought speed, then hide other headers normally else { headerLayout?.UpdateHeadersTranslationY(newScrollY, navigationBarHeight, navigationBar.TranslationY, isNavigationBarFloating, isNavigationBarScrollable); } } // Hide navigation bar based on scroll only else { navigationBar.TranslationY = Math.Min(0, Math.Max(-navigationBarHeight + RootPage.Instance.SafeAreaInsest.Top, navigationBar.TranslationY - delta)); navigationBarY = navigationBar.TranslationY; headerLayout?.UpdateHeadersTranslationY(newScrollY, navigationBarHeight, navigationBarY, isNavigationBarFloating, isNavigationBarScrollable); } } // If navigation bar is visible or hidden else { headerLayout?.UpdateHeadersTranslationY(newScrollY, navigationBarHeight, navigationBarY, isNavigationBarFloating, isNavigationBarScrollable); } }
public override void CancelAnimation() { AnimationExtensions.AbortAnimation(Target, "BounceOut"); }