Skip to content
This repository has been archived by the owner on Sep 28, 2021. It is now read-only.

Allow zero for duration parameter for centerOn method #158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Sc4ramouche
Copy link

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 the duration parameter passed to centerOn method. Currently, specifying 0 leads to having 300 as a fallback value due to the fact that zero is treated as a falsy value, thus the expression 0 || 300 returns 300. 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 the duration parameter, but it didn't work. To achieve the desired outcome I currently need to specify 1 or 0.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!

@Sc4ramouche
Copy link
Author

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant