I would share modified version. Now I do not know why sections are not true for function 'isActive' at the first scroll down. On the other hand on scroll up everything seems to work fine. Do you have any ideas about it ?
https://stackblitz.com/edit/vitejs-vite-dpegxw?file=src%2FApp.jsx,src%2Findex.css,src%2Fmain.jsx