Skip to content

Commit

Permalink
feat(motionPath): allow rotate prop to take angle offset
Browse files Browse the repository at this point in the history
Closes #39.
  • Loading branch information
colinmeinke committed Jul 25, 2016
1 parent ad721e8 commit 021ff16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,11 @@ one shape to the next.
more accurate (smoother) the animation. Only relevant
for shapes that include curves.
- `easing` is either a *string* or a *function*.
- `rotate` is a *boolean* that defines if the shape should
be rotated inline with the direction of the motion path.
- `rotate` is either:
- a *boolean* that defines if the shape should
be rotated with the angle of the motion path
- a *number* to offset the angle of the motion
path and rotate the shape
- `name` is a *string* that can be used to reference this
animation by objects in a
[`timeline()` function](#timeline-function)
Expand Down
3 changes: 2 additions & 1 deletion src/core/shape/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,15 @@ const motionPathOffset = ( animation, motionPath ) => {
const motionPathShapes = ( animation, motionPath, shapes ) => {
const { rotate: r = false } = motionPath;
const { angle, x, y } = motionPathOffset( animation, motionPath );
const a = typeof r === 'number' ? ( r + angle ) % 360 : angle;

if ( x || y ) {
return shapes.map(({ points, ...shape }) => {
if ( points ) {
let p = offset( points, x, y );

if ( r ) {
p = rotate( p, angle );
p = rotate( p, a );
}

return { ...shape, points: p };
Expand Down

0 comments on commit 021ff16

Please sign in to comment.