I am trying to change the color of a scrollbar at a certain position but using window.scrollY seems to trigger errors:
const navBar = computed<NavigationBarData>(
() => {
if (window.scrollY < 100) {
return {
secondaryNavColor: 'transparent',
primaryNavColor: 'transparent',
}
} else {
return {
secondaryNavColor: 'gray-lighten-3',
primaryNavColor: 'surface',
}
}
}
)
My error this generates is:
500
Cannot read properties of undefined (reading 'scrollY')
Why can we not use window.scrollY in vue3/nuxt3?