Skip to content

Commit

Permalink
Fix Ui::Animations::Simple's .start() and .change() methods
Browse files Browse the repository at this point in the history
Unlike the `.change()` method, which configures a running animation to
go to a different state, the `.start()` method should first set the
initial opacity value, then animate.

It is fixed by making sure the private `.prepare()` method always sets
`from`, rather than ignoring it when the animation is already running.
  • Loading branch information
kolayne committed Jan 5, 2025
1 parent da44ac8 commit 1da57c5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ui/effects/animations.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,16 +381,19 @@ inline void Simple::change(
anim::transition transition) {
Expects(_data != nullptr);

prepare(0. /* ignored */, duration);
prepare(_data->value /* keep the old value */, duration);
startPrepared(to, duration, transition);
}

inline void Simple::prepare(float64 from, crl::time duration) {
const auto isLong = (duration > kLongAnimationDuration);
if (!_data) {
if (_data) {
_data->value = from;
if (!isLong) {
_data->tracker.restart();
}
} else {
_data = std::make_unique<Data>(from);
} else if (!isLong) {
_data->tracker.restart();
}
if (isLong) {
_data->tracker.release();
Expand Down

0 comments on commit 1da57c5

Please sign in to comment.