scroll-into-view / scroll-into-view-if-needed

Element.scrollIntoView ponyfills for things like "if-needed" and "smooth"

Home Page:https://scroll-into-view.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dealing with a Fixed Navbar

dliebner opened this issue · comments

Let's say we've got a fixed navbar at 60px height. Is there an easy way to pass in / factor in that 60px offset for scroll position calculations? For example, if we try to scroll to the top of an element, with a fixed navbar at the top of the screen, the top part of the element will be covered the navbar.

I met the same issue,and i didn't find how to settle it in V2.

OK. I have found this way. We can set scroll-margin-top: 60px in style. This is a new feature in #1197 .But it didn't be written into README yet. It worked on scroll-into-view-if-needed@^3.1.0 or smooth-scroll-into-view-if-needed@^2.0.2 by my test.