I was trying to add a class to Header after some scrolling so I added an IntersectionObserver to Header component:
export default {
data() {
return {
test: false
}
},
mounted () {
const observer = new IntersectionObserver(
function(entries, observer) {
entries.forEach(entry => {
console.log(entry)
this.test = true
})
});
observer.observe(this.$refs['header']);
}
}
Somehow it is not working, because test
variable won't change. Console.log
executes properly every time, so I believe it is some reactivity problem? Maybe I created IntersectionObserver in a wrong place? I was messing a bit with this.$nextTick()
and this.$set
, but none of them helped. Cheers