fuse-open / fuselibs

Fuselibs is the Uno-libraries that provide the UI framework used in Fuse apps
https://npmjs.com/package/@fuse-open/fuselibs
MIT License
176 stars 72 forks source link

Expressions: Add a time and/or framecount to expressions #727

Open COCPORN opened 6 years ago

COCPORN commented 6 years ago

So that you can express things as a function of time, automatic scrollers, etc.

Duckers commented 6 years ago

You mean something like seconds() which will return the number of seconds since the expression was rooted?

COCPORN commented 6 years ago

Something like that. It would make it easy to make continuous animations of scrollview position, waves by putting it through the sin/cos-expressions, etc. I did post this to the wrong issue tracker, however, but it might be of general interest.

Also After Effects wiggle expression would be nice.

Duckers commented 6 years ago

There are things like <Cycle /> and <Spin />, can that do the trick?

COCPORN commented 6 years ago

It is very limited compared. But disregard the issue, I will implement it on my own.

mortoray commented 6 years ago

I've wanted this feature as well. I thought I entered an issue for myself, but I can't find it anymore.

We have to be careful with naming here. Something like seconds() would be ambiguous enough to not need strict guarantees as to what we mean. Seconds since when, can it restart, etc.

mortoray commented 6 years ago

Hmm, I'm actually uncertain of this now. I think it might be open to abuse quite a bit. It's very rare that you'd want something to animate all the time. You'd usually want to animate within a WhileVisible or WhileActive trigger, in which case Cycle makes more sense.

Perhaps a Timer type would make this less error-prone. This is a behaviour that can be placed inside a trigger. It exposes a Value that updates while rooted. It'd also allow for extended options, like updating things once per second instead.

kusma commented 6 years ago

A timer-object that somehow allows people to read it's time from an expression sounds neat. I agree that a general-purpose "time since whenever" seems a bit scary. Or maybe we could add a function to read out the progress of an animator or something like that instead of adding something new?

mortoray commented 6 years ago

The progress of triggers can be read {Property myTrigger.Progress}. I suppose we could also add a value to Cycle that can be read (relatively cheap). Combined with a generic behavior of Timer this should cover all use-cases without any odd-semantics.