private async void PressBeganEffect(object sender, PositionEventArgs e)
        {
            lock (TapLocker)
                _isTaped = false;

            if (AnimationEffect == AnimationType.atScaling)
            {
                await this.ScaleTo(1 + (AnimationScale / 100), AnimationSpeed, Easing.CubicOut);
            }
            else if (AnimationEffect == AnimationType.atFlashingTap && !_animateFlashBox.IsVisible)
            {
                _animateFlashBox.TranslationX = e.PositionX - _mainContent.Width / 2;
                _animateFlashBox.IsVisible    = true;
                _animateFlashBox.Animate(
                    "AnimateFlashBox",
                    t => t * _mainContent.Width,
                    x =>
                {
                    _animateFlashBox.WidthRequest = x;

                    var delta = _mainContent.Width / 2 - Math.Abs(_animateFlashBox.TranslationX) - x / 2;
                    if (delta < 0)
                    {
                        if (_animateFlashBox.TranslationX < 0)
                        {
                            _animateFlashBox.TranslationX -= delta;
                        }
                        else
                        {
                            _animateFlashBox.TranslationX += delta;
                        }
                    }
                },
                    16, AnimationSpeed, Easing.SinOut,
                    (x, y) =>
                {
                    _animateFlashBox.WidthRequest = 1;
                    _animateFlashBox.IsVisible    = false;
                });
            }
            else if (AnimationEffect == AnimationType.atFlashing && !_animateFlashBox.IsVisible)
            {
                _animateFlashBox.TranslationX = 0;
                _animateFlashBox.IsVisible    = true;
                _animateFlashBox.Animate(
                    "AnimateFlashBox",
                    t => t * _mainContent.Width,
                    x => _animateFlashBox.WidthRequest = x,
                    16, AnimationSpeed, Easing.SinOut,
                    (x, y) =>
                {
                    _animateFlashBox.WidthRequest = 1;
                    _animateFlashBox.IsVisible    = false;
                });
            }
        }
Beispiel #2
0
        public static async void AnimateBackground(BoxView boxViewBackground)
        {
            void Forward(double input) => boxViewBackground.AnchorY  = (float)input;
            void Backward(double input) => boxViewBackground.AnchorY = (float)input;

            while (true)
            {
                boxViewBackground.Animate(name: "forward", callback: Forward, start: 0, end: 1, length: 4000, easing: Easing.SinIn);
                await Task.Delay(6000);

                boxViewBackground.Animate(name: "backward", callback: Backward, start: 1, end: 0, length: 4000, easing: Easing.SinIn);
                await Task.Delay(6000);
            }
        }
Beispiel #3
0
        public static void animatePin(Action <double> updateCallback, Action <double, bool> finishedAction, uint animationLength)
        {
            if (updateCallback == null)
            {
                return;
            }

            animatorView.Animate(
                "pinAnimation",
                updateCallback,
                length: animationLength,
                easing: Easing.Linear,
                finished: finishedAction);
        }
        public async Task AnimationWithFinished()
        {
            var source = new TaskCompletionSource <bool>();

            var view      = new BoxView();
            var animation = new Animation(v =>
            {
                view.Opacity = v;
            }, 1, 0);

            view.Animate("Fade", animation, finished: (a, b) => source.TrySetResult(true));

            await source.Task;

            Assert.AreEqual(0, view.Opacity);
        }
Beispiel #5
0
        private void HidePopup()
        {
            _background?.Animate("BackgroundFadeOut",
                                 v => _background.Opacity = v, 0.8, 0,
                                 finished: (x1, x2) =>
            {
                RootLayout.Children.Remove(_background);
                _background = null;
            });

            _detailsPopupView?.Close(this, () =>
            {
                RootLayout.Children.Remove(_detailsPopupView);
                _detailsPopupView = null;
            });
        }
Beispiel #6
0
#pragma warning disable 1998 // considered for removal
        async Task Animate(BoxView box)
#pragma warning restore 1998
        {
            box.Animate("animate", d => d, d => { }, 100, 1);
        }