Lerp precision.
[string-lerp.git] / string-lerp.js
index 46a55bf..6c240e4 100644 (file)
             var part = nlerp(+sourcePart, +targetPart, amount);
             var sourcePoint = sourcePart.indexOf(".");
             var targetPoint = targetPart.indexOf(".");
-            var point = Math.max(
+            var point = Math.round(nlerp(
                 sourcePoint >= 0 ? (sourcePart.length - 1) - sourcePoint : 0,
-                targetPoint >= 0 ? (targetPart.length - 1) - targetPoint : 0);
+                targetPoint >= 0 ? (targetPart.length - 1) - targetPoint : 0,
+                amount));
             targetParts[i] = part.toFixed(point);
         }
         return targetParts.join("");