Пример #1
0
		void ITimeline.Seek(TimeSpan offset)
		{
			long msOffset = (long)offset.TotalMilliseconds;
			IValueAnimator targetAnimator = null;
			foreach (var animator in _animators)
			{
				if (msOffset < animator.Duration)
				{
					targetAnimator = animator;
					break;
				}
				msOffset -= animator.Duration;
			}

			if (targetAnimator != _currentAnimator)
			{
				_currentAnimator.Cancel();
				_currentAnimator = targetAnimator;
			}

			_currentAnimator.CurrentPlayTime = (long)offset.TotalMilliseconds; //Offset is CurrentPlayTime (starting point for animation)

			if (State == TimelineState.Active || State == TimelineState.Paused)
			{
				CoreDispatcher.Main.RunAsync(
					CoreDispatcherPriority.Normal,
					() =>
					{
						OnFrame(_currentAnimator);

						_currentAnimator.Pause();
					});
			}
		}
Пример #2
0
        partial void OnFrame(IValueAnimator currentAnimator)
        {
            if (currentAnimator is CPUBoundAnimator <ColorOffset> cpuAnimator)
            {
                var easing   = cpuAnimator.GetEasingFunction();
                var newValue = easing.Ease(
                    currentAnimator.CurrentPlayTime,
                    _startingValue ?? default(ColorOffset),
                    _finalValue,
                    currentAnimator.Duration);

                SetValue(newValue);
                return;
            }
            // TODO: https://github.com/unoplatform/uno/issues/2947
            else
            {
                // since there is no gpu-bound implementation,
                // make sure at least a value is set when the animation is ended/paused.
                if (!currentAnimator.IsRunning)
                {
                    SetValue(_finalValue);
                }
            }
        }
        // This class is not implemented for Android
        partial void OnFrame(IValueAnimator currentAnimator)
        {
            if (!_errorReported && this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Error))
            {
                _errorReported = true;

                this.Log().Error($"{GetType()} is not supported on this platform.");
            }
        }
Пример #4
0
 partial void OnFrame(IValueAnimator currentAnimator)
 {
     if (currentAnimator.AnimatedValue is Java.Lang.Float javaFloat)
     {
         SetValue(javaFloat.DoubleValue());
     }
     else
     {
         SetValue(currentAnimator.AnimatedValue);
     }
 }
 /// <summary>
 /// Set the value on a new frame
 /// </summary>
 partial void OnFrame(IValueAnimator currentAnimator)
 {
     if (!this.GetIsHardwareAnimated() || currentAnimator is DiscreteFloatValueAnimator)
     {
         SetValue(currentAnimator.AnimatedValue);
     }
     else
     {
         this.SetValueBypassPropagation(currentAnimator.AnimatedValue);
     }
 }
        partial void OnFrame(IValueAnimator currentAnimator)
        {
            if (currentAnimator is CPUBoundAnimator <ColorOffset> cpuAnimator)
            {
                var easing   = cpuAnimator.GetEasingFunction();
                var newValue = easing.Ease(
                    currentAnimator.CurrentPlayTime,
                    _startingValue ?? default(ColorOffset),
                    _finalValue,
                    currentAnimator.Duration);

                SetValue(newValue);
                return;
            }

            // TODO
        }
Пример #7
0
		/// <summary>
		/// Creates a new animator and animates the view
		/// </summary>
		private void Play()
		{
			InitializeAnimators();//Create the animator

			if (!EnableDependentAnimation && this.GetIsDependantAnimation())
			{ // Don't start the animator its a dependent animation
				return;
			}

			UseHardware();//Ensure that the GPU is used for animations

			_currentAnimator = _animators.First();
			if (BeginTime.HasValue)
			{ // Set the start delay
				_currentAnimator.StartDelay = (long)BeginTime.Value.TotalMilliseconds;
			}

			_currentAnimator.Start();
			State = TimelineState.Active;
		}
Пример #8
0
		private void OnAnimatorEnd(int i)
		{
			var nextAnimatorIndex = i + 1;

			// if it's the last animation part, in the end of the DoubleAnimationUsingKeyFrames
			if (nextAnimatorIndex == KeyFrames.Count)
			{
				if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
				{
					this.Log().Debug("DoubleAnimationUsingKeyFrames has ended.");
				}

				OnEnd();
				_startingValue = null;
			}
			else
			{
				_currentAnimator = _animators[nextAnimatorIndex];
                _currentAnimator.Start();
			}
		}
Пример #9
0
		partial void OnFrame(IValueAnimator currentAnimator);
Пример #10
0
 partial void OnFrame(IValueAnimator currentAnimator)
 {
     SetValue(currentAnimator.AnimatedValue);
 }