From 8fe8ab80bb4863ba6dd644f393ffcefc64ce08ea Mon Sep 17 00:00:00 2001 From: Daniel Barber Date: Sat, 23 Jan 2021 06:21:42 -0500 Subject: [PATCH 1/2] minMax not required for undefined spring params --- src/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index af520bb5..23940ac2 100644 --- a/src/index.js +++ b/src/index.js @@ -76,10 +76,10 @@ function parseEasingParameters(string) { function spring(string, duration) { const params = parseEasingParameters(string); - const mass = minMax(is.und(params[0]) ? 1 : params[0], .1, 100); - const stiffness = minMax(is.und(params[1]) ? 100 : params[1], .1, 100); - const damping = minMax(is.und(params[2]) ? 10 : params[2], .1, 100); - const velocity = minMax(is.und(params[3]) ? 0 : params[3], .1, 100); + const mass = is.und(params[0]) ? 1 : minMax(params[0], .1, 100); + const stiffness = is.und(params[1]) ? 100 : minMax(params[1], .1, 100); + const damping = is.und(params[2]) ? 10 : minMax(params[2], .1, 100); + const velocity = is.und(params[3]) ? .1 : minMax(params[3], .1, 100); const w0 = Math.sqrt(stiffness / mass); const zeta = damping / (2 * Math.sqrt(stiffness * mass)); const wd = zeta < 1 ? w0 * Math.sqrt(1 - zeta * zeta) : 0; From d897f2bd272f1d5a62359f2a4a8392dbc7483cf3 Mon Sep 17 00:00:00 2001 From: Daniel Barber Date: Sat, 23 Jan 2021 06:24:36 -0500 Subject: [PATCH 2/2] shortened spring solver return --- src/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 23940ac2..035018c5 100644 --- a/src/index.js +++ b/src/index.js @@ -93,8 +93,7 @@ function spring(string, duration) { } else { progress = (a + b * progress) * Math.exp(-progress * w0); } - if (t === 0 || t === 1) return t; - return 1 - progress; + return (t === 0 || t === 1) ? t : 1 - progress; } function getDuration() {