-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
v9 canary #808
Closed
Closed
v9 canary #808
Conversation
This file contains 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
aleclarson
force-pushed
the
feat/spring-class
branch
3 times, most recently
from
September 9, 2019 18:14
21ffd77
to
921c10f
Compare
|
This was referenced Sep 10, 2019
Closed
aleclarson
force-pushed
the
feat/spring-class
branch
from
September 18, 2019 16:03
8b48058
to
3af91c0
Compare
aleclarson
force-pushed
the
feat/spring-class
branch
from
September 18, 2019 23:58
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
aleclarson
force-pushed
the
feat/spring-class
branch
2 times, most recently
from
September 21, 2019 00:58
a4f1506
to
ecabfaa
Compare
This was referenced Sep 21, 2019
Closed
aleclarson
force-pushed
the
feat/spring-class
branch
from
September 27, 2019 16:52
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.
aleclarson
force-pushed
the
feat/spring-class
branch
from
May 2, 2020 22:50
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.
aleclarson
force-pushed
the
feat/spring-class
branch
from
May 3, 2020 19:13
499eeea
to
efd9253
Compare
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
useTransition
todos hereMake
Controller#reset
work with asyncto
propAdd
pause
prop toController
(which powersuseSpring
etc)Add
DelayQueue
for pauseable delaysDemo for
config.frequency/damping
vsconfig.tension/friction
Write tests for:
SpringValue#pause
methodInterpolation
object asto
propnested
to
function propsDetails
First, an example demonstrating one of the main inspirations for this PR:
But wait, there's more!
New features 🎉
Added the
SpringValue
class, which controls the animation of one value or an array of values.FrameLoop
now deals withSpringValue
objects instead ofController
objects.SpringValue
object has aqueue
property that stores anything you pass to theupdate
method. When ready, you call thestart
method to flush thequeue
, which may or may not trigger an animation (depending on which props were given).Every prop of an
animated
component now supports anyFluidValue
) object as its value. This allows any observable library to integrate with react-spring. In fact, theSpringValue
class extends theFluidValue
class. 🔥The
to
prop also allows passing anyFluidValue
, and that spring will animate towards theFluidValue
on every frame.immediate
prop is true, that spring will stick to theFluidValue
instead of animating to it.from
prop also allows this, but it only recaches theFluidValue
's raw value when first animated and when thereset
prop is true.to
props (eg: an array or async function) can now be nested without cancelling each other:onChange
prop (passed touseSpring
for example) lets you observe changes to all of your values (one animated value per call).SpringValue#finish
method lets you skip to the end of an animation, which calls anyonRest
callbacks.AnimatedInterpolation
class was replaced by theInterpolation
class. It caches its computed value, instead of recomputing it on everyget
call.config.bounce
prop lets you create a bouncing animation using a spring. You specify this alongsidetension
,friction
, etcThe
config.frequency
prop (aka: the "natural frequency") is a new alternative toconfig.tension
that defines how frequent the spring bounces in a frictionless environment.The
config.damping
prop (aka: the "damping ratio") can only be used withconfig.frequency
defined. Theconfig.damping
prop defaults to1
when undefined, which means the spring will never bounce. Set this value between0
and1
to control the spring's bounciness.The
config.round
prop rounds the animated value to the nearest multiple of the given number.immediate
,reset
, andcancel
props can each equal a boolean, a function, an array of keys, or a single key.Breaking changes ☠️
The
useTransition
hook has been rewritten from the ground up. More info at feat: useTransition rewrite #809The
Controller#destroy
method is now calleddispose
, and theSpringValue
class has a method with the same name. Note: Only call thedispose
method on objects you've created manually (usingnew
syntax).The
Controller#reset
method now works like{ reset: true }
passed touseSpring
The
Controller#stop
method now takes a string or an array of strings. No more variable arguments.Event props like
onChange
andonRest
only affect a single animation, which means you must define them whenever you update theto
prop. Alternatively, you can define them on thedefaultProps
object property by passing thedefault: true
prop. 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#_diff
andController#_animate
methods) to theSpringValue#_update
method. Take a peek and you'll see a new approach to diffing, where the props are applied to theanimation
property on an individual basis, instead of the old approach, where every prop was cached in an internalprops
property before updating theanimation
object. 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).from
andto
).Bug fixes 🐛
ref
prop. They should be re-rendered on every animation frame now, as expected.Other changes 🚧
The
Animated
nodes no longer form a graph of dependencies. Instead, theSpringValue
objects are passed as props to animated components, and theAnimatedProps
object tracks whichSpringValue
objects exist in its props at any given time. This removes the need for anAnimated#updatePayload
method and themoveChildren
helper once used by theController
class.Animated components now cache any
FluidValue
objects 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
FrameLoop
now 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
FrameLoop
class, which is only useful in the case of native-driven springs (which we don't have yet).