Last active
March 8, 2017 17:54
-
-
Save tkh44/a3d4446841fe75530a3c7612d5a5d2b2 to your computer and use it in GitHub Desktop.
Found this on a react-motion issue. It will create a spring values based on duration for react-motion's spring.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// tl;dr ...set the duration of a spring animation | |
export const configw = (sec, overdamping) => { | |
const s = overdamping <= 0 | |
? 1 - overdamping | |
: 1 / Math.sqrt(1 + Math.pow(2 * Math.PI / Math.log(1 / (overdamping * overdamping)), 2)) | |
const ks = (2 * Math.PI / sec) / Math.max(Math.sqrt(1 - s * s), 0.5) | |
const c = 2 * ks * s | |
return [ks * ks, c] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment