Skip to content

Conversation

@aleclarson
Copy link
Contributor

@aleclarson aleclarson commented Sep 7, 2019

Closed in favor of #808

dbismut and others added 3 commits September 5, 2019 11:09
- Calculate velocity for "decay" and "easing" animations
- When "config.clamp" is a number, it becomes the coefficient of restitution
- Account for dropped frames in "decay" and "easing" animations
- Fixed "config.velocity" to be per ms instead of per sec
- Implement variable timesteps as described in pmndrs#678
- Bounce animations can be done with "config.clamp" > 0
- The default value of "config.precision" is now derived from the distance between "to" and "from"
This prop lets you continue an easing animation from a specific point in time (specified with a progress value from 0 to 1).
Every `Spring` object controls the animation of a single value or an array of values.
The `FrameLoop` now deals with `Spring` objects instead of `Controller` objects.
Each spring has its own queue, but the `Spring#update` method skips the queue.
Use the `Spring#push` and `Spring#start` methods to operate the queue.

The diffing algorithm has been moved from the `Controller#_diff` and `Controller#_animate`
methods over to the `Spring#_update` method. Take a peek and you'll see a new approach
to diffing, where the props are applied to the `animation` property on an individual basis,
instead of the approach, where every prop was cached in an internal `props` property before
updating the `animation` object. This new approach gives us more control over the edge
cases of various props.

The abstract `Dependency` class was added. Any `Dependency` object can be passed to
an animated component, which will transiently update their native props whenever a
dependency has its value changed. This opens up more possibilities for performant
updates to rendered components.

Any `Dependency` object can be the "to" prop of another spring, and that spring will
animate towards the dependency's value on every frame. If the "immediate" prop is true,
that spring will stick to the dependency's value instead of animating to it. This works
with the "from" prop too, except (of course) the dependency's value is only used on first
animation and after reset.

The `Animated` nodes no longer form a graph of dependencies. Instead, the `Spring` objects
are passed as props to animated components, and the `AnimatedProps` object tracks which
`Spring` objects exist in its props at any given time. This removes the need for an
`Animated#updatePayload` method and the `moveChildren` helper once used by the `Controller`
class.

The `AnimatedInterpolation` class was replaced by the `To` class, which inherits from the
`Spring` class. This gives all the powers of `Spring` to interpolated values, like change
listeners with the `onChange` method, or even converting a `To` spring into a normal spring
by calling its `update` method.

The `Controller#destroy` method is now called `dispose`, and the `Spring` class has a method
with the same name.

The `Spring#onChange` method lets users observe changes to their springs. Likewise, the
`onChange` prop lets you observe changes for a single animation.

The `Spring#finish` method lets users skip to the end of an animation.

Event props like `onChange` and `onRest` only affect a single animation, which means you must
supply them on every `update` call, or add them to the `defaultProps` object of the spring.

Animated components now cache any `Dependency` objects found in their props (except if they're
nested in an object *other than* the top-level props, an animated style, an animated transform,
or an animated array).

Fixed a small bug with animated function components that don't forward their `ref` prop.
They should be re-rendered on every animation frame now, as expected.

Got rid of the concept of "batched frame updates" (in the `FrameLoop` class), which is only
useful in the case of native-driven springs (which we don't have yet).

The `Controller#stop` method now takes a string or an array of strings. No more variable arguments.

The `FrameLoop` now updates its springs in topological order, based on which springs depend on
the values of other springs.

Async `to` props (eg: an array or async function) can now be nested without cancelling each other.

Regression: Async `to` props do not respect the `delay` prop.

Regression: The `onStart` and `onRest` props have new signatures, because all event props are
called once per `Spring` object. We probably want to batch these calls when these event props
are supplied to a `Controller` object.

Regression: The `onFrame` prop of `Controller` is never called. I need to figure out where that
prop will be stored, and how the `FrameLoop` class will call it.
- lots of work on typings
- separated "runAsync" from Controller so that SpringValue can use it
- integrated "runAsync" into SpringValue (might need more work)
- added "props.reset" and better "props.cancel" support to "runAsync"
- the Controller class is now properly subscribed to the frameloop while 1+ of its SpringValue objects is animating
- added "get" method to Controller
- the "start" method of Controller now promises a single "AnimationResult" instead of an array of arrays
- the "start" method of SpringValue now promises a single "AnimationResult" instead of an array of them
@aleclarson aleclarson closed this Sep 9, 2019
@pmndrs pmndrs locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants