Skip to content

Instantly share code, notes, and snippets.

@marcusradell
Last active December 18, 2019 23:06
Show Gist options
  • Save marcusradell/3c3d84483581310596fb1e58665bc969 to your computer and use it in GitHub Desktop.
Save marcusradell/3c3d84483581310596fb1e58665bc969 to your computer and use it in GitHub Desktop.
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