A
A
alaskafx2021-04-29 16:15:54
Vue.js
alaskafx, 2021-04-29 16:15:54

How to make smooth scroll in vue.js (not to anchor)?

I have no idea how to make smooth scrolling / scrolling in a vue.js project.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2021-04-29
@Seasle

window.scrollTo({
    top: Y,
    left: X,
    behavior: 'smooth'
});

If this option does not suit you, you can requestAnimationFramesolve it with the help. Or do you want the scroll to have "physics" (speed, etc.)?

A
Alexander, 2021-04-30
@Aleksandr-JS-Developer

Hang a scroll handler ( ) on the container of the root component and, for example, do the necessary magic @scroll="method($event)"requestAnimationFrame

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question