Last active
December 18, 2019 23:06
-
-
Save marcusradell/3c3d84483581310596fb1e58665bc969 to your computer and use it in GitHub Desktop.
Notes from https://www.youtube.com/watch?v=wOsqWoszMDI
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
document.body.style.setProperty('--value', "pink"); | |
// :root { | |
// --value: brown; | |
// } | |
// background: var(--value); | |
// 0 could become a problem as there is no delay. | |
const animFrameStream = interval(0, animationFrameScheduler); | |
const smoothMoveStream = animFrameStream.pipe( | |
withLatestFrom(moveStream, (frame, move) => move), | |
scan(lerp) | |
); | |
// Linear Interpolation | |
const lerp = (current, next) => { | |
const dx = next.x - current.x; | |
const dy = next.y - current.y; | |
const ratio = 0.1; | |
return { | |
x: current.x + dx * ratio, | |
y: current.y + dy * ratio | |
} | |
} | |
// Design your week RxJS https://codepen.io/davidkpiano/pen/0069791abf6250e65b6a42ac8e2a213c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment