From 2e0f56948f55b2a7f805fc9fb8f1bbf8bf87a183 Mon Sep 17 00:00:00 2001 From: Matt Perry Date: Sun, 6 Aug 2017 12:23:12 +0100 Subject: [PATCH] updating spring calc --- .../stories/popmotion/Spring.js | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/packages/popmotion-react/stories/popmotion/Spring.js b/packages/popmotion-react/stories/popmotion/Spring.js index adc3c209b..180d21615 100644 --- a/packages/popmotion-react/stories/popmotion/Spring.js +++ b/packages/popmotion-react/stories/popmotion/Spring.js @@ -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 () => ( { - 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 }) => (