BugiDev / react-native-calendar-strip

Easy to use and visually stunning calendar component for React Native.
MIT License
949 stars 327 forks source link

scrollerPaging. The strip spins on 6 days for the first time, then – on 7 days #269

Closed artcherenkov closed 3 years ago

artcherenkov commented 3 years ago

If the week starts on Monday, I want the bar to scroll until the next or previous Monday, but for some reason, when the first scroll, the bar spins for 6 days, and then properly - for 7 days.

My config:

<CalendarStrip
  scrollable
  scrollerPaging
  style={{ height: 200, paddingTop: 20, paddingBottom: 10 }}
  calendarColor={'#3343ce'}
  iconContainer={{ flex: 0.1 }}
/>

ezgif com-gif-maker

Someone know, how to fix it?

Andrerm124 commented 3 years ago

I'm also facing this issue. Not sure on the cause but it makes the app look a little confusing at times.

peacechen commented 3 years ago

This may be a bug in the scrolling algorithm. Please use the demo project in this repo to debug and submit a PR.

https://github.com/BugiDev/react-native-calendar-strip#development-with-sample-application

peacechen commented 3 years ago

This has been published in 2.2.0

Thanks @psolom for the PR

ozanmanav commented 3 years ago

@peacechen Same issue happening on master branch. I'm setting starting of date as Monday. But it is again changing to Sunday when we scroll to next week.

psolom commented 3 years ago

@ozanmanav Make sure you set minDate and maxDate params, and the difference between values is a multiple of 7 - number of days in a week (14, 21, 28, etc). Works for me in versions of 2.2.0+

ozanmanav commented 3 years ago

@psolom Thanks for answer. Can you share a piece of code for this situation? In my case, it starts with Monday when it doesn't scroll at all, but when it scrolls it always becomes Sunday on the first day. The props I am currently using for this are as follows.

  const startingDate = 2021-04-19

    scrollable = {true}
    scrollerPaging = {true}
    useIsoWeekday = {false}
    startingDate = {startingDate}

The first view is as follows: image

But if I scroll it works like this: image

ozanmanav commented 3 years ago

I think I found the problem. This problem happens when I close the left selector and right selector. When you open them, the problem disappears. I guess there is actually a little slip.

I made an issue about this: #291

rjuevesano commented 3 years ago

@ozanmanav try this solution on this issue https://github.com/BugiDev/react-native-calendar-strip/issues/266