|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
}); |
|
|
|
D.assert( |
|
|
|
this._ticker != null, |
|
|
|
"AnimationController.forward() called after AnimationController.dispose()\n" + |
|
|
|
"AnimationController methods should not be used after calling dispose." |
|
|
|
); |
|
|
|
this._direction = _AnimationDirection.forward; |
|
|
|
if (from != null) { |
|
|
|
this.setValue(from.Value); |
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
}); |
|
|
|
D.assert( |
|
|
|
this._ticker != null, |
|
|
|
"AnimationController.reverse() called after AnimationController.dispose()\n" + |
|
|
|
"AnimationController methods should not be used after calling dispose." |
|
|
|
); |
|
|
|
this._direction = _AnimationDirection.reverse; |
|
|
|
if (from != null) { |
|
|
|
this.setValue(from.Value); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public TickerFuture animateTo(float target, TimeSpan? duration = null, Curve curve = null) { |
|
|
|
D.assert( |
|
|
|
this._ticker != null, |
|
|
|
"AnimationController.animateTo() called after AnimationController.dispose()\n" + |
|
|
|
"AnimationController methods should not be used after calling dispose." |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
TickerFuture animateBack(float target, TimeSpan? duration, Curve curve = null) { |
|
|
|
D.assert( |
|
|
|
this._ticker != null, |
|
|
|
"AnimationController.animateBack() called after AnimationController.dispose()\n" + |
|
|
|
"AnimationController methods should not be used after calling dispose." |
|
|
|
); |
|
|
|
curve = curve ?? Curves.linear; |
|
|
|
this._direction = _AnimationDirection.reverse; |
|
|
|
return this._animateToInternal(target, duration, curve); |
|
|
|
} |
|
|
|
|
|
|
|
TickerFuture _animateToInternal(float target, TimeSpan? duration = null, Curve curve = null) { |
|
|
|
|
|
|
new _InterpolationSimulation(this._value, target, simulationDuration.Value, curve)); |
|
|
|
} |
|
|
|
|
|
|
|
public TickerFuture repeat(float? min = null, float? max = null, TimeSpan? period = null) { |
|
|
|
public TickerFuture repeat(float? min = null, float? max = null, bool reverse = false, TimeSpan? period = null) { |
|
|
|
min = min ?? this.lowerBound; |
|
|
|
max = max ?? this.upperBound; |
|
|
|
period = period ?? this.duration; |
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
}); |
|
|
|
return this.animateWith(new _RepeatingSimulation(min.Value, max.Value, period.Value)); |
|
|
|
|
|
|
|
D.assert(max >= min); |
|
|
|
D.assert(max <= this.upperBound && min >= this.lowerBound); |
|
|
|
D.assert(reverse != null); |
|
|
|
return this.animateWith(new _RepeatingSimulation(this._value, min.Value, max.Value, reverse, period.Value)); |
|
|
|
} |
|
|
|
|
|
|
|
public TickerFuture fling(float velocity = 1.0f) { |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
class _RepeatingSimulation : Simulation { |
|
|
|
internal _RepeatingSimulation(float min, float max, TimeSpan period) { |
|
|
|
internal _RepeatingSimulation(float initialValue, float min, float max, bool reverse, TimeSpan period) { |
|
|
|
this._initialT = (max == min) ? 0.0f : (initialValue / (max - min)) * (period.Ticks / TimeSpan.TicksPerSecond); |
|
|
|
D.assert(this._initialT >= 0.0f); |
|
|
|
readonly bool _reverse; |
|
|
|
readonly float _initialT; |
|
|
|
float t = (timeInSeconds / this._periodInSeconds) % 1.0f; |
|
|
|
return MathUtils.lerpFloat(this._min, this._max, t); |
|
|
|
float totalTimeInSeconds = timeInSeconds + this._initialT; |
|
|
|
float t = (totalTimeInSeconds / this._periodInSeconds) % 1.0f; |
|
|
|
bool _isPlayingReverse = ((int)(totalTimeInSeconds / this._periodInSeconds)) % 2 == 1; |
|
|
|
|
|
|
|
if (this._reverse && _isPlayingReverse) { |
|
|
|
return MathUtils.lerpFloat(this._max, this._min, t); |
|
|
|
} else { |
|
|
|
return MathUtils.lerpFloat(this._min, this._max, t); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public override float dx(float timeInSeconds) { |
|
|
|