Scrolling on agendaList does not work even though code is exactly the same as the demo code

366 Views Asked by At

I have an AgendaList component that displays event data. Within my component, I also have an expandable Calendar component. When trying to click a new date on the expandable calendar I expect the agendaList component to scroll to that specific day but that does not happen at all. The scrolling does not seem to work. When I scroll manually through the agendaList and then click on a new date in the expandable Calendar the agendaList suddenly scrolls back to the very first item.

Has anyone else have an idea as to why that happens?

I tried setting up everything just like in the code demo but that also did not make any difference. Code demo: https://github.com/wix/react-native-calendars/blob/master/example/src/screens/expandableCalendarScreen.tsx

edit: I am using expo

Edit 2: Because I was out of options, I looked at the actual code for the agendaList. In there, I found the function that does the scrolling (scrollToSection). This function runs the scrollToLocation function with the following parameters.

    list?.current.scrollToLocation({
        animated: true,
        sectionIndex: sectionIndex,
        itemIndex: 0,
        viewPosition: 0,
        viewOffset: (constants.isAndroid ? sectionHeight.current : 0) + viewOffset
    });

Once I changed itemIndex from 0 to 1 the scrolling was working all of a sudden. Does anyone have an idea as to why this fixed my scrolling issue?

0

There are 0 best solutions below