-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
Feature request: RAF updates. #333
Comments
Hello @DylanPiercey. Currently, Baobab commits on |
@Yomguithereal currently I am using the update event, however AFAIK it is called immediately after a commit which as you said is done with setTimeout 0. This means that I would have to manually do something like: var frame = null;
baobab.on("update", function () {
if (frame) cancelAnimationFrame(frame);
frame = requestAnimationFrame(function () {
// work with DOM
frame = null;
});
});
// vs
baobab.on("update-frame", function () {
// work with DOM
}); Since I think this would be a semi common use-case it would be handy to have it built in. Also, I have been doing this with sync commits, but I'm not sure what the implications of sync commits are. If it helps any I am planning to use baobab with Tusk. |
So, if we go to the bottom of the issue here, the only problem is that Baobab does not use |
That sounds about right if there isn't any comparability issues. Will this only work if you have async commits? |
There should not be compatibility issues. Node or older browsers would fallback to |
@Yomguithereal you could use something like https://github.com/component/raf. Sadly it won't work in node thanks to "window", but would be easily modified. |
Thanks @DylanPiercey. I had some different opinions lately about |
@christianalfoni: with |
Sorry for the double question. You answered this one on #337. |
@Yomguithereal is this available in 2.0? |
Also; in node we should fallback to setTimeout of 16ms for consistency if this makes it in. |
@Yomguithereal Yeah, animation frame :-) |
So this can be closed? |
Not yet. |
on node you could use |
Often when using baobab (or similar libraries) a ui update follows a state update.
React handles requestAnimationFrame automatically but if you are using a different framework or are doing some imperative stuff that isn't the case.
It would be nice if baobab could emit an "animation" event which would be called on animation frame after an update. Similar to immstructs
next-animation-frame
.The text was updated successfully, but these errors were encountered: