Skip to content

Conversation

@LeonMatthes
Copy link
Contributor

Allow animate properties with a binding to re-query their PropertyAnimation whenever the binding to the property changes.

Closes #348

self.animation_data.borrow_mut().reset();
let mut animation_data = self.animation_data.borrow_mut();
animation_data.reset();
if let Some((details, start_time)) = (self.compute_animation_details)() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might not be good to call something that can query other properties from mark_dirty or we could end up in bad recursion.
Was it a problem to query it on the next frame in ShouldStart as before?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I wanted to discuss this anyhow. This is a quick fix to be able to use current_tick() for an initial test and definitely not optimal. We'll probably want to modify the Animation::Transition type so that we can make the time Option.

Another downside to evaluating the PropertyAnimation inside evaluate is that from a user perspective it becomes very hard to predict when the animation data is computed.
It doesn't happen when the binding to the animated property changes, but rather when the animated property is first read, which could be unintuitive.
@NigelBreslaw agress that the values should remain constant after the animation starts ( #348 (comment) ), but this makes it somewhat hard to determine when exactly "the animation starts".

But maybe documenting this behavior of "the animation data is queried when the property is first read after modification", is probably good enough.

This avoids re-evaluating the PropertyAnimation during the mark_dirty
function and re-evaluates it on the first call to evaluate.
This has been replaced by set_animated_binding_for_transition
The `state` variable is referenced by both expressions, so using a
single CodeBlock is easier.
In the generated code, use tuple destructuring to convert the Instant to
an Option<Instant>.
@LeonMatthes LeonMatthes force-pushed the lm/348-animate-reactive branch from 23bd875 to 969095e Compare January 9, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Animate bindings are not reactive and can't reference property set or initialized after

2 participants