Skip to content

Instantly share code, notes, and snippets.

@amccloud
Created July 3, 2018 03:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amccloud/844be0c7c033eb92d12377b1901a6173 to your computer and use it in GitHub Desktop.
Save amccloud/844be0c7c033eb92d12377b1901a6173 to your computer and use it in GitHub Desktop.
const polarToCartesian = ({ angle, radius }) => ({
x: radius * Math.cos(angle),
y: radius * Math.sin(angle)
});
const ball = document.querySelector('#b .ball');
const ballStyler = styler(ball);
let pointerTracker;
physics({
from: { angle: 0, radius: 3 },
velocity: { angle: 5, radius: 0 }
}).pipe(polarToCartesian)
.start(ballStyler.set);
const startTracking = () => {
pointerTracker = pointer({
x: ballStyler.get('x'),
y: ballStyler.get('y')
}).start(ballStyler.set);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment