Skip to content

Instantly share code, notes, and snippets.

@idmontie
Created April 8, 2018 02:30
Show Gist options
  • Save idmontie/11bc0d02104eefab67dbc153ba9b1dd0 to your computer and use it in GitHub Desktop.
Save idmontie/11bc0d02104eefab67dbc153ba9b1dd0 to your computer and use it in GitHub Desktop.
import { compose, mapProps } from 'recompose';
const startX = 0;
const startY = 0;
const FollowingRectangle = compose(
mousePosition(),
tween({
tween: linear,
duration: 1000,
defaultStart: () => startX,
end: props => props.x
}),
mapProps(props => ({ ...props, x: props.current })),
tween({
tween: linear,
duration: 1000,
defaultStart: () => startY,
end: props => props.y
}),
mapProps(props => ({ ...props, y: props.current })),
)(Rectangle);
const App = () => (
<FollowingRectangle />
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment