Answer the question
In order to leave comments, you need to log in
Is the js code written correctly and can it be optimized / written better somehow?
Good day!
While freelancing, I somehow stumbled upon an order where the layout was divided into sections and when the mouse was scrolling, the site smoothly scrolled to the next / previous section.
At that time, I didn’t know js at all, so I didn’t know how to make such functionality.
Now I learned something and wrote the following code in a whole day:
https://codepen.io/Kononov_D/pen/GeqbaX
And I would like people who understand better than me to advise what could be done better / point out mistakes (yes, the functions are called crookedly, obliquely, but this is not a mistake)
I also do not quite understand how you can make a controlled scroll to an element, because here is a design
window.scrollTo({
top: offsetTop,
behavior: "smooth"
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question