React Fullcalendar scroll handler not working

34 views Asked by At

I'm trying to set up a custom context menu with fullcalendar (v5.11) in React.

When the timeline scrolls, I'd like the Context Menu to disappear, so I tried this:

    useEffect(() => {
        function handleScroll(){
            if(contextMenu.toggled){
                resetContextMenu()
            }
        }
        document.addEventListener('scroll', handleScroll);
        return () => document.removeEventListener('scroll', handleScroll);
    }, [])

The resetContextMenu function resets x and y to 0, and toggled to false.

But it doesn't work, the listener is not passed in the handleScroll function.

By adding true in the 3rd props of the addEventListener function, I managed to get it to work, but the page lags a lot with this option enabled, so I don't think this is the right solution. Like this :

document.addEventListener('scroll', handleScroll, true);

I can't find anything in the fullcalendar docs for a scroll handler, do you have any ideas? We should be able to do something this simple...

Thank you very much

0

There are 0 answers