And using pageYOffset is a px based rule - might not be the best option when doing responsive work. The Intersection ratio is an alternative to consider...
I was wondering of ways I could have changed it in such a way that it would not respond to scrolling after a number to pixels because in my mobile version of the website I made, it would change the content of what I wanted to be changed after a number of pixels. Long story short, this method only worked of laptop but not on mobile so I had to hide whatever I did on laptop for mobile to avoid the bug. Thanks Nicolai for telling me about Intersection ratio and I will look further into it
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Do not use scroll event for this. IntersectionObserver is born for this kind of stuff and performs way better:
developer.mozilla.org/en-US/docs/W...
Wow, thanks. I never knew about IntersectionObserver. It really performs much better
And using pageYOffset is a px based rule - might not be the best option when doing responsive work. The Intersection ratio is an alternative to consider...
I was wondering of ways I could have changed it in such a way that it would not respond to scrolling after a number to pixels because in my mobile version of the website I made, it would change the content of what I wanted to be changed after a number of pixels. Long story short, this method only worked of laptop but not on mobile so I had to hide whatever I did on laptop for mobile to avoid the bug. Thanks Nicolai for telling me about Intersection ratio and I will look further into it