-
-
Notifications
You must be signed in to change notification settings - Fork 735
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
Add support for navigating with numberOfMonths
#196
Comments
I like this idea. As default it should work as it does now (e.g. skipping only one month), but we could add a new prop to change the behavior of |
Thank you for the fast reply. |
Would you send a PR? :) |
Sure, I'll do that ASAP |
I just noticed there's still this case: What is the expected behavior? |
Actually the wrong value there is in |
It's coming from the |
Thanks, so we have two approach here:
We had a similar issue where [we preferred] the first option, but I'm open to change my mind about it! |
I think it's the developer's responsibility, but we should also have a reasonable default behavior. getStateFromProps = props => {
const initialMonth = Helpers.startOfMonth(props.initialMonth);
let currentMonth = initialMonth;
if (
props.pagedNavigation &&
props.numberOfMonths > 1 &&
props.fromMonth
) {
const diffInMonths = Helpers.diffInMonths(currentMonth, fromMonth);
currentMonth = Helpers.addMonths(
fromMonth,
Math.floor(diffInMonths / props.numberOfMonths) * props.numberOfMonths
);
}
return {currentMonth};
} What do you think? Do I add it to the PR? |
@zaygraveyard could you send the change above in an another PR? I'd prefer to deal with one issue at time (and we need tests for it as well) Thanks a lot! |
Yeah sure 😄 |
The code for the second issue is ready, but it requires that #197 gets merged. |
Add support for paged navigation. (fixes #196)
I'm using this component with
numberOfMonths = 4
and I need the navigation between months to be more like changing the page of months. E.g:The visible months can be [1, 2, 3, 4] or [5, 6, 7, 8] or [9, 10, 11, 12]
So the visible months can never be [3, 4, 5, 6] for example.
I'm not setting the
fromMonth
andtoMonth
props so I can never run into the case where some of the months are not allowed.But I understand that it can problematic.
One solution would be to only render the allowed months. E.g:
If the
fromMonth = 2
andtoMonth= 3
then we render [2, 3]If the
fromMonth = 2
andtoMonth= 5
then we render [2, 3, 4], [5]An other solution would be to say that the only change to the current behavior is that
showNextMonth()
andshowPreviousMonth()
will change thecurrentMonth
bynumberOfMonths
instead of1
.I would be happy to create a PR
The text was updated successfully, but these errors were encountered: