Skip to content

Commit

Permalink
duration: make sure reverse() works even after duration stops
Browse files Browse the repository at this point in the history
  • Loading branch information
ammen99 committed Apr 4, 2024
1 parent bba125a commit ba5ead7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/duration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ bool wf::animation::duration_t::running()

void wf::animation::duration_t::reverse()
{
std::chrono::milliseconds remaining(this->priv->get_duration() -
this->priv->get_elapsed());
auto total_duration = this->priv->get_duration();
auto elapsed = std::max(this->priv->get_elapsed(), (int64_t)total_duration);
auto remaining = std::chrono::milliseconds(total_duration - elapsed);
this->priv->start_point = std::chrono::system_clock::now() - remaining;
this->priv->reverse = !this->priv->reverse;
}
Expand Down

0 comments on commit ba5ead7

Please sign in to comment.