MarceloPrado / flash-calendar

The fastest React Native calendar 📆⚡
https://marceloprado.github.io/flash-calendar/
MIT License
1.09k stars 33 forks source link

[feat]: Add ability to scroll to a week row #37

Closed danibonilha closed 5 months ago

danibonilha commented 5 months ago

First of all, thanks @MarceloPrado for this library it is so much better than any other available library for react native.

This PR aims to give more flexibility to users by exposing scrollToOffset method to calendarRef and also adds a new ref method to scroll to a week row, scrollToWeek. The motivation for this new method comes from my project's design with a fixed weekHeader but I figured it could be useful for other people.

My project example:

https://github.com/MarceloPrado/flash-calendar/assets/20520102/0a40554c-f517-44e5-8797-611f7eeee50e

Flash calendar storybook:

https://github.com/MarceloPrado/flash-calendar/assets/20520102/20d7f056-d1f7-4633-8d0e-e701e837b6c4

I'd also suggest to change the name of scrollToDate to scrollToMonth, because at first I thought the behavior was to scroll to the date/row itself rather than to MonthHeader, but that would have an impact on the API so I understand it might not be a priority since the docs explain the behavior.

changeset-bot[bot] commented 5 months ago

🦋 Changeset detected

Latest commit: 2a69fbc378074be150944de34432252c9428aa2f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ------------------------------- | ----- | | @marceloterreiro/flash-calendar | Major |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

danibonilha commented 5 months ago

Hey @MarceloPrado thanks for the review! I don't have the bandwidth this week to address your comments, if there's any rush to merge this, please feel free to make edits. Otherwise I'll happily update it as soon as things calm down.

MarceloPrado commented 5 months ago

@danibonilha don't worry, I'll make the changes and get it over the finish line. Thanks again for the contribution 🙏

MarceloPrado commented 5 months ago

@danibonilha good news: I was able to fix the need for the -2 offset: fabbd70

https://github.com/MarceloPrado/flash-calendar/assets/8047841/d9d4edf5-8c0a-4ba0-a231-b504dd7a736e