Skip to content

Commit

Permalink
updating spring calc
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Perry authored and Matt Perry committed Aug 6, 2017
1 parent 71aec89 commit 2e0f569
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions packages/popmotion-react/stories/popmotion/Spring.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,27 @@ import React from 'react';
import { spring } from '../../../../lib/popmotion';
import { MotionValue } from '../../src';

const springProps = {
const makeSpring = (value, to) => spring({
stiffness: 1000,
damping: 500,
mass: 3
};
mass: 3,
from: value.get(),
to,
velocity: value.getVelocity(),
onUpdate: value
});

export default () => (
<MotionValue
onStateChange={{
on: ({value}) => {
spring({
from: value.get(),
to: 800,
...springProps,
velocity: value.getVelocity(),
onUpdate: value
}).start()
console.log(value.getVelocity())
makeSpring(value, 800).start();
},
off: ({value}) => spring({
from: value.get(),
to: 0,
...springProps,
velocity: value.getVelocity(),
onUpdate: value
}).start()
off: ({value}) => {
console.log(value.getVelocity())
makeSpring(value, 0).start();
}
}}
>
{({ v, state, setStateTo }) => (
Expand Down

0 comments on commit 2e0f569

Please sign in to comment.