Sometimes, due to your in-page navigation or some other fixed position element, you need to actually scroll to a point before the actual element, so that it doesn’t get covered. The native behavior would not give it the lead space and you’d see some of the element’s content covered by a static element.
In scenarios where you can’t redesign the html structure or css to give the element more padding, you pretty much have to use javascript to get the window-x position of the element.
In scenarios where you can’t redesign the html structure or css to give the element more padding, you pretty much have to use javascript to get the window-x position of the element.