From 9b6b0595ae06e2605976a0c14a3df45dff1d2da5 Mon Sep 17 00:00:00 2001 From: d38u6 Date: Thu, 15 Oct 2020 14:09:33 +0200 Subject: [PATCH] add 'onlyPositiveInt' transform function and using it to transform 'particleCount' --- src/confetti.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/confetti.js b/src/confetti.js index baa45ee..ce0ff78 100644 --- a/src/confetti.js +++ b/src/confetti.js @@ -206,6 +206,10 @@ ); } + function onlyPositiveInt(number){ + return number < 0 ? 0 : Math.floor(number); + } + function randomInt(min, max) { // [min, max) return Math.floor(Math.random() * (max - min)) + min; @@ -412,7 +416,7 @@ var animationObj; function fireLocal(options, size, done) { - var particleCount = prop(options, 'particleCount', Math.floor); + var particleCount = prop(options, 'particleCount', onlyPositiveInt); var angle = prop(options, 'angle', Number); var spread = prop(options, 'spread', Number); var startVelocity = prop(options, 'startVelocity', Number);