Scroll to heading should be configurable with an offset

Created on 2 October 2024, 3 months ago

Problem/Motivation

With the use of the native scrollintoview method, the browser scroll to the heading in sort that the top of heading element match the top of the browser window.

We don't have (anymore) a setting wich allows us to configure an offset, allowing to scroll to the element but with an offset in px. This is particularly useful if you have a sticky bar navigation, and allow us to configure the height of this bar navigation as an offset for the scroll. So the browser will scroll to the heading until it will be just under the bar navigation sticked, and not behind.

Proposed resolution

Add a new setting "scroll offset", a value in px. If this value is set then we add the following CSS rules to the html element :

scroll-padding-top: VALUE px;

There is a lack of support for an offset for the native scrollintoview method, but we can use this property to adjust the scrolling behavior

See https://stackoverflow.com/questions/24665602/scrollintoview-scrolls-just...

Remaining tasks

Agreed on solution and write patch

User interface changes

New setting added. Default empty.

Feature request
Status

Active

Version

3.0

Component

Code

Created by

🇫🇷France flocondetoile Lyon

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024