Created
March 16, 2017 13:38
-
-
Save paldepind/81aa21be706737528d04226040ac4c00 to your computer and use it in GitHub Desktop.
Player timeline implemented in Funnel
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
const model = (animation: Animation) => fgo(function* model({ playPauseS, replayS }: ToModel) { | |
const playingB: Behavior<boolean> = yield sample(scan((_, b) => !b, false, playPauseS)); | |
const playingSpeedB = map((b) => b ? 1 : 0, playingB); | |
const initialTimeB = yield sample(integrate(playingSpeedB)); | |
const positionB = yield sample(switcher(initialTimeB, snapshot(integrate(playingSpeedB), replayS))); | |
return [{ positionB, playingB }, {}]; | |
}); | |
const view = ({ playingB, positionB }: ToView): any => [ | |
button({output: {click: "playPauseS"}}, icon(playingB.map((b) => b ? "pause" : "play_arrow"))), | |
button({output: {click: "replayS"}}, icon("replay")), | |
slider({ position: positionB }) | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment