Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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);
        }