Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent infinity loop when 'particleCount' is negative number. #127

Merged
merged 1 commit into from
Oct 15, 2020

Conversation

d38u6
Copy link
Contributor

@d38u6 d38u6 commented Oct 15, 2020

When 'particleCount' is negative number, while loop in this line
var temp = particleCount; while (temp--)
it becomes infinite. So I suggest create only positive integer transform function and pass it instead Math.floor.

Comment on lines +209 to +212
function onlyPositiveInt(number){
return number < 0 ? 0 : Math.floor(number);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add 'onlyPositiveInt' transform function

@@ -412,7 +416,7 @@
var animationObj;

function fireLocal(options, size, done) {
var particleCount = prop(options, 'particleCount', Math.floor);
var particleCount = prop(options, 'particleCount', onlyPositiveInt);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use 'onlyPositiveInt' function instead Math.floor

@catdad catdad merged commit cbf7d96 into catdad:master Oct 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants