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

Fix smoothTime set to 0 not work #44

Closed
Ami-OS opened this issue Sep 25, 2023 · 1 comment
Closed

Fix smoothTime set to 0 not work #44

Ami-OS opened this issue Sep 25, 2023 · 1 comment

Comments

@Ami-OS
Copy link

Ami-OS commented Sep 25, 2023

In this line:

options.smoothTime = Number(options.smoothTime) || wZoomDefaultOptions.smoothTime;

https://github.com/worka/vanilla-js-wheel-zoom/blob/727db6934e4d84d562c87a5e44bb66fccca7f894/src/wheel-zoom.js#L372C60-L372C60

Has something problem, since smoothTime option value can set to be 0, but the || operator means check "falsely" (false == 0), so if we set that the 0, || operator will assume that the value is false lead to be apply default value.

So I think we could use ?? operator, who will check undefined or null instead of the "falsely".

Fix:

options.smoothTime = Number(options.smoothTime) ?? wZoomDefaultOptions.smoothTime;
@worka
Copy link
Owner

worka commented Sep 26, 2023

thanks

@worka worka closed this as completed Sep 26, 2023
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

No branches or pull requests

2 participants