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

Click the button to switch to the new/previous week #96

Closed
tnghia944 opened this issue May 15, 2021 · 6 comments · Fixed by #99
Closed

Click the button to switch to the new/previous week #96

tnghia944 opened this issue May 15, 2021 · 6 comments · Fixed by #99
Labels
type: feature enhancements or new features type: question

Comments

@tnghia944
Copy link

tnghia944 commented May 15, 2021

hi all
instead of scrolling left to right, can i click on the button to do this
Screen Shot 2021-05-15 at 7 32 47 PM
I am currently using goToDate, is that the best way? , when I already know index + 1 / index -1
const dateTarget = moment(currentMoment).add(isNext ? 1 : -1, 'w')
this.goToDate(dateTarget);

@pdpino
Copy link
Collaborator

pdpino commented May 15, 2021

Hi @tnghia944, currently, there is no specific way to change pages programatically, other than swiping. As a workaround, you can use goToDate(date), providing a date in the next or prev week.

const dateTarget = moment(currentMoment).add(isNext ? 1 : -1, 'w')
this.goToDate(dateTarget);

I think using this code would work (being inside WeekView.js), though I haven't tested it.

@pdpino
Copy link
Collaborator

pdpino commented May 15, 2021

I'd say we can implement methods to move programatically, something like goToNextPage() and goToPrevPage().
What do you think @hoangnm? I think it would be straight-forward by reusing code from goToDate()

@pdpino pdpino added type: feature enhancements or new features type: question labels May 15, 2021
@pdpino
Copy link
Collaborator

pdpino commented May 16, 2021

I implemented both methods in a PR: goToNextPage() and goToPrevPage()

@hoangnm let me know what you think!

@tnghia944, for now, you can test this from this branch in my fork 🙂

@tnghia944
Copy link
Author

hi @pdpino pd
thank you for your support, now when i press next button everything is ok, i can see the calendar scrolll left to right very well, but when i press the prev button the calendar still changes but the not scroll, you can see this?

@pdpino
Copy link
Collaborator

pdpino commented May 16, 2021

Yes, I see the same. The calendar moves to the previous page, but the animation is not smooth.

This has to do with this old issue: #39. As a summary:

  • When the user moves to a date that has not been rendered, a date object has to be added to an array
  • If the date is appended (added to the end of the array), everything tends to be smooth (moving to the next page, in this case).
  • If the date is prepended (added to the beginning of the array), things may not be so smooth (in this case, the animation for the prev page).

For now, there is no easy way to fix that in this library 🙁, as this is an issue from react-native VirtualizedList (and FlatList and ScrollView).

@pdpino
Copy link
Collaborator

pdpino commented May 16, 2021

A comment about smooth vs laggy behavior:

  • If the primary use case of your app is to go to the past (previous pages), you can set the prop prependMostRecent={true}, and things will be smooth to the previous pages (and laggy to the future pages).
  • If the primary use case of your app is to go to the future (next pages), you should leave prependMostRecent={false} (the default): things will be smooth to the future (and laggy to the past).
  • If you need both the past and the future, one of them will be laggy and the other smooth, sadly 🙁 . We hope this can be improved by react-native soon.

@hoangnm hoangnm reopened this May 16, 2021
@tnghia944 tnghia944 changed the title Click the button to switch to the new/previous week tuần Click the button to switch to the new/previous week May 17, 2021
@hoangnm hoangnm closed this as completed Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature enhancements or new features type: question
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants