Coder Social home page Coder Social logo

Comments (4)

ogoffart avatar ogoffart commented on July 21, 2024

Thanks for filling a bug.

The thing is that the binding evaluation is lazy, and the animation starts from the last evaluated value.

So in summary, the binding for your property is (pseudo-code):

y: !self.expanded ? self.start-y : 'state-animation-to'(0);

when you change the value of start-y, the value of y is marked as dirty but not re-evaluated yet.
If you don't query the value before changing the state, the state animation will start at the last computed value of the property.

You found the work around which is to query that property before the animation start.
One change we could do is re-evaluate the property of the previous state before as the start of the animation. But that also might not be correct :-/

Slightly related is #4811 in which animation restarts with an outdated value.

from slint.

Justyna-JustCode avatar Justyna-JustCode commented on July 21, 2024

Thanks for your reply!

One change we could do is re-evaluate the property of the previous state before as the start of the animation. But that also might not be correct :-/

This is precisely what I would expect. Could you elaborate on why you think it might not be correct? I can't think of any example. If the property is already marked dirty when the transition starts, it was changed before the transition was triggered. In my opinion, the order here implies that the transition should use the updated value.

When I access (query) the value, it gets updated. But the animation also (well, conceptually) queries the value to know what to start from. So, the behavior should be the same.

Am I missing something? 😉

from slint.

ogoffart avatar ogoffart commented on July 21, 2024

The case i'm thinking about is this:

states [
  A when ...: { p: 0; in => { animate p { duration 1s } }
  B when ...: { p: 100; in => { animate p { duration 1s } }
]
  • state A is active, p is 0.
  • state B becomes active, p is set to animate from 0 to 100 in 1s. animations start
  • after 0.5s, state A becomes active again and want to set the property back to 0.

When we change back from B to A, the property p is dirty because the time changes. But we don't want to re-evaluate the start position of state B either.

from slint.

Justyna-JustCode avatar Justyna-JustCode commented on July 21, 2024

I might be missing or misunderstanding something, and I don't know the implementation details.
But:

When we change back from B to A, the property p is dirty because the time changes.

The p property is dirty because it was updated by the B-state transition (which seems good). When we switch back to state A, we should use the latest property value as a start position (right?). So, the dirty state should be taken into consideration, and the property value should be evaluated before the A-state transition starts.

But we don't want to re-evaluate the start position of state B either.

Why do we consider B at all? Shouldn't the B-state animation just stop (be aborted) when we switch back to state A?

from slint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.