Smooth Scroll

Conventional way

const hoge = hoge.getBoundingClientRect(); window.scrollTo({ left : hoge.left + window.pageXOffset, top: hoge.top + window.pageYOffset, behavior: 'smooth',
})
Enter fullscreen mode
Exit fullscreen mode

Recently way

hoge.scrollIntoView({behavior: "smooth"})
Enter fullscreen mode
Exit fullscreen mode

Viewport version

document.documentElement.clientHeight
Enter fullscreen mode
Exit fullscreen mode

Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top
Free & easy ad network.