Open Sc4ramouche opened 3 years ago
My bad, I didn't really put the effort to look through existing pull requests. #147 already solves the problem I'm facing. Nevertheless, this PR solves it in a bit different manner. Feel free to close this PR in case you merge #147.
Hi there! First of all, thanks for maintaining this cool project! 💪
This pull request aims to allow developers to specify
0
as a valid value for theduration
parameter passed tocenterOn
method. Currently, specifying0
leads to having300
as a fallback value due to the fact that zero is treated as a falsy value, thus the expression0 || 300
returns300
. In our use case, it is required just to show part of the big image, and animation is unnecessary in the scenario we try to implement. My intuition was to just specify zero for theduration
parameter, but it didn't work. To achieve the desired outcome I currently need to specify1
or0.1
as animation duration, which is, in my opinion, might be a bit confusing for newcomers.I think we could utilize nullish coalescing here. Luckily, there's no additional configuration required as TypeScript 3.9.2 already supports it.
Please, let me know what do you think about this!