-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: add Spring class #807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closed in favor of #808