-
Notifications
You must be signed in to change notification settings - Fork 26
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
DimensionsSpring #242
Comments
For the sake of a more terse (and flexible) API, why not just have an operator? Since all the // spring$ is a Point2DSpring
// .remap doesn't exist yet
const DimensionsSpring = spring$.remap({ x: 'width', y: 'height' }); |
Interesting idea.
const dimensionsSpring = new Point2DSpring();
const collapsedDimensionsAsPoint2D$ = elementDimensions$.rename({ x: 'width', y: 'height' });
const expandedDimensionsAsPoint2D$ = viewportDimensions$.rename({ x: 'width', y: 'height' });
subscribe({
sink: dimensionsSpring.initialValue$,
source: closedDimensionsAsPoint2D$,
});
subscribe({
sink: dimensionsSpring.destination$,
source: expandedDimensionsAsPoint2D$,
});
subscribe({
sink: containerStyle$,
source: combineStyleStreams({
width$: dimensionsSpring.value$.pluck('x'),
height$: dimensionsSpring.value$.pluck('y'),
})
}) Relabeling each of the inputs is definitely a solution, but I'm inclined to think it would be easier to work with an API that thought in terms of the correct labels in the first place, especially since breaking Thoughts? Nice seeing you pop in! I'm used to this issue tracker just being a place for me to leave ideas for Future Me. 😝 |
Makes sense. And yeah, I'm slowly working on a generic Reactive Animations library (less detailed than Material Motion, but more flexible in that it will provide adapters to other animation libs), so there's a lot of common ideas in here, and I'm happy to toss them back and forth with you 😄 It's called RxAnimate if you're curious - it's built with RxJS (I don't want to force developers to learn yet another Observable syntax, haha) |
Now that Rx is lettable (and thus not a massive dependency), I'm flirting with the idea of turning MM into a bag of lettable operators that could be used with it. I'm booked the rest of the week, but let's chat soon. MM was written declaratively primarily because it makes it more easy to tool, but that's a longer-term goal now than it was when we started, so there might be some assumptions worth revisiting. If we have enough common ground, merging our projects could be a good move. I know @souporserious is interested in this space too. I've been waiting to cut a prerelease of MM to see how it plays with Bazel (which is quickly becoming usable, but isn't there yet). Maybe I should just cut one now so it's easier for people-who-aren't-me to play with. |
That's essentially what RxAnimate is going to be, with two key distinctions, in the form of something called a "patch" (you can think of it as a higher-order operator, and yes, it's related to Origami patches): A patch is a function that:
That way you can take a source observable, chain together patches, and render them at the end, similar to how Origami works: Also, since you're not forced to merge many observables into one, you can optimize animations so that values are recalculated only when they absolutely need to be recalculated, rather than when anything unrelated changes. (sorry if this is unrelated to the issue!) |
This all sounds amazing! I'm not sure I can help much here with the core stuff 😅, but I'm definitely willing to help test things out and create examples, help find bugs, etc. 😄 |
I believe in you, guy I've never worked with. 😉 |
Have either of you been following PopMotion? The new beta seems to be incorporating similar features https://github.com/Popmotion/popmotion/tree/beta |
Yes, we're talking about the upcoming Popmotion on the Animation At Work slack - you two should join if you haven't yet! |
FWIW I'm also watching the repo and check in occasionally to see what's happening 🙂. I'm really excited about material-motion-js and in this case also looking forward to RxAnimate! Currently I'm building a gesture driven app demo with Rx.js (which isn't quite finished yet) and really having fun. I'm also not sure if I can contribute much to core features, but I'd love to build some demos etc. once this is ready. |
@amannn I'd love to see the repo. Feel free to chat with us on the Slack as well! |
@davidkpiano I'll ping you once it's ready. I think it'll likely be around Christmas though, I don't have much time to work on it currently. I just joined the Slack group 🙂 |
We currently have a 1D spring (
NumericSpring
) and a 2D spring (Point2DSpring
). It would be nice to have aDimensionsSpring
, which is really just aPoint2DSpring
with the axes renamed.Point2DSpring
can probably be refactored into a function that generates a class for a multidimensional spring of a given shape. Then, it should be as easy asThe text was updated successfully, but these errors were encountered: