Skip to content
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

Port xstream#tween to @cycle/time #13

Closed
Widdershin opened this issue Feb 12, 2017 · 4 comments
Closed

Port xstream#tween to @cycle/time #13

Widdershin opened this issue Feb 12, 2017 · 4 comments

Comments

@Widdershin
Copy link
Member

Tween is the only time based operator in xstream that @cycle/time does not implement.

@Widdershin
Copy link
Member Author

I don't want to include tween in core right now, because I think the current API surface is quite large. I want to support extra operators, so that we can provide niche operators without requiring people to bundle them.

This could look like:

import {makeTimeDriver, mockTimeSource} from '@cycle/time';
import tween from '@cycle/time/extra/tween';

const drivers = {
  Time: makeTimeDriver({extra: {tween}})
}

const mockTime = mockTimeSource({extra: {tween}});

This will also open the way up to custom operators from users.

@staltz
Copy link
Member

staltz commented Feb 14, 2017

Also, I'm not sure tween() is the best way for doing animations. I used it in http://matrixmultiplication.xyz and in Firefox I still get some glitches, and I have no idea yet why how the glitch happens.

@staltz
Copy link
Member

staltz commented May 29, 2017

Actually @Widdershin the glitches in matrixmultiplication might be due to the lack of rAF usage. I think tween doesn't need to be implemented in Cycle Time as long as we have something like sources.Time.burst(1500 /*ms*/) where burst returns a Stream of numbers from 0 to 1 that lasts 1500ms. With such a stream, you can interpolate those numbers using typical cartesian Math and do whatever animations you want.

In other words, the tween logic can be pure math living under a specific library which is agnostic to Cycle.js. And Cycle Time just needs to provide a burst of numbers between 0 and 1. The duration 1500ms can be measured by calling Date.now() (or some equivalent way of getting timestamps), this way we can decouple rAF framerate from animation duration.

@staltz
Copy link
Member

staltz commented May 29, 2017

PS: Ben Lesh's recent talk on animations in RxJS using rAF might be relevant as an inspiration or reference. https://www.youtube.com/watch?v=X_RnO7KSR-4 You might know most of this so it's okay to watch it in 2x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants