-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
v9 canary #808
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
v9 canary #808
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
Closed
21ffd77 to
921c10f
Compare
|
|
This was referenced Sep 10, 2019
Closed
8b48058 to
3af91c0
Compare
dd4f67a to
b34b911
Compare
🤘 |
aleclarson
added a commit
that referenced
this pull request
Sep 20, 2019
aleclarson
added a commit
that referenced
this pull request
Sep 20, 2019
aleclarson
added a commit
that referenced
this pull request
Sep 20, 2019
aleclarson
added a commit
that referenced
this pull request
Sep 20, 2019
a4f1506 to
ecabfaa
Compare
This was referenced Sep 21, 2019
Closed
f9ab364 to
4dea3e1
Compare
aleclarson
added a commit
that referenced
this pull request
Sep 27, 2019
aleclarson
added a commit
that referenced
this pull request
Sep 27, 2019
This ensures the next "start" call will start animating even if the "to" value is identical to the previous "to" value (before "set" was called)
When the "to" value is fluid, the goal value can change at any time before "onRest" is called. So we need to compute the goal value from within onRest. Otherwise, the "finished" property (on the animation result) might not be accurate.
instead of an abstract value. This keeps the compiler from initializing `idle` to undefined in the constructor, which was triggering an error because SpringValue#idle is a getter w/o a setter.
But noop updates created by the "loop" prop are still never repeated.
This only affects SpringValue objects owned by a Controller object.
a221046 to
60041ab
Compare
FrameLoop is incompatible with r3f's render loop, because of how the FrameLoop calls r3f's `invalidate` function inside r3f's global effects queue. In doing that, the `invalidate` call is ignored, and the frameloop is effectively paused.
499eeea to
efd9253
Compare
Contributor
Author
|
Closed in favor of #978 |
aleclarson
added a commit
that referenced
this pull request
May 3, 2020
aleclarson
added a commit
that referenced
this pull request
May 3, 2020
aleclarson
added a commit
that referenced
this pull request
May 3, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
(Forked from #797)
Status: Basically done 🥳
Try the latest canary here.
Todos
The remaining
useTransitiontodos hereMake
Controller#resetwork with asynctopropAdd
pauseprop toController(which powersuseSpringetc)Add
DelayQueuefor pauseable delaysDemo for
config.frequency/dampingvsconfig.tension/frictionWrite tests for:
SpringValue#pausemethodInterpolationobject astopropnested
tofunction propsDetails
First, an example demonstrating one of the main inspirations for this PR:
But wait, there's more!
New features 🎉
Added the
SpringValueclass, which controls the animation of one value or an array of values.FrameLoopnow deals withSpringValueobjects instead ofControllerobjects.SpringValueobject has aqueueproperty that stores anything you pass to theupdatemethod. When ready, you call thestartmethod to flush thequeue, which may or may not trigger an animation (depending on which props were given).Every prop of an
animatedcomponent now supports anyFluidValue) object as its value. This allows any observable library to integrate with react-spring. In fact, theSpringValueclass extends theFluidValueclass. 🔥The
toprop also allows passing anyFluidValue, and that spring will animate towards theFluidValueon every frame.immediateprop is true, that spring will stick to theFluidValueinstead of animating to it.fromprop also allows this, but it only recaches theFluidValue's raw value when first animated and when theresetprop is true.toprops (eg: an array or async function) can now be nested without cancelling each other:onChangeprop (passed touseSpringfor example) lets you observe changes to all of your values (one animated value per call).SpringValue#finishmethod lets you skip to the end of an animation, which calls anyonRestcallbacks.AnimatedInterpolationclass was replaced by theInterpolationclass. It caches its computed value, instead of recomputing it on everygetcall.config.bounceprop lets you create a bouncing animation using a spring. You specify this alongsidetension,friction, etcThe
config.frequencyprop (aka: the "natural frequency") is a new alternative toconfig.tensionthat defines how frequent the spring bounces in a frictionless environment.The
config.dampingprop (aka: the "damping ratio") can only be used withconfig.frequencydefined. Theconfig.dampingprop defaults to1when undefined, which means the spring will never bounce. Set this value between0and1to control the spring's bounciness.The
config.roundprop rounds the animated value to the nearest multiple of the given number.immediate,reset, andcancelprops can each equal a boolean, a function, an array of keys, or a single key.Breaking changes ☠️
The
useTransitionhook has been rewritten from the ground up. More info at feat: useTransition rewrite #809The
Controller#destroymethod is now calleddispose, and theSpringValueclass has a method with the same name. Note: Only call thedisposemethod on objects you've created manually (usingnewsyntax).The
Controller#resetmethod now works like{ reset: true }passed touseSpringThe
Controller#stopmethod now takes a string or an array of strings. No more variable arguments.Event props like
onChangeandonRestonly affect a single animation, which means you must define them whenever you update thetoprop. Alternatively, you can define them on thedefaultPropsobject property by passing thedefault: trueprop. Note: Event props provided inuseSpring(() => props)will be treated as "default props" (which means they'll be used when an animation has no handler of its own).The diffing algorithm has been moved (from the
Controller#_diffandController#_animatemethods) to theSpringValue#_updatemethod. Take a peek and you'll see a new approach to diffing, where the props are applied to theanimationproperty on an individual basis, instead of the old approach, where every prop was cached in an internalpropsproperty before updating theanimationobject. This new approach gives us more control over the edge cases of various props, but some props may behave differently (in rare use cases only).fromandto).Bug fixes 🐛
refprop. They should be re-rendered on every animation frame now, as expected.Other changes 🚧
The
Animatednodes no longer form a graph of dependencies. Instead, theSpringValueobjects are passed as props to animated components, and theAnimatedPropsobject tracks whichSpringValueobjects exist in its props at any given time. This removes the need for anAnimated#updatePayloadmethod and themoveChildrenhelper once used by theControllerclass.Animated components now cache any
FluidValueobjects found in their props (unless they're nested in an object other than the top-level props, an animated style, an animated transform, or an animated array).The
FrameLoopnow updates its springs in topological order, based on which springs depend on the values of other springs.Erased the concept of "batched frame updates" from the
FrameLoopclass, which is only useful in the case of native-driven springs (which we don't have yet).