mirror of https://github.com/freeCodeCamp/devdocs
- Set `document.scrollingElement` as the scrolling element for scrolling to anchors when the app is mobile mode to enhance support in newer browsers. The CSS View Module spec considers `document.documentElement`/`<html>` to be the standard scrolling element and that is what appears to be used in the latest Firefox and Chrome. However, some older browsers and even the current Safari use `document.body` as the scrolling element which is why I suspect the original code used `document.body`. Since some browsers scroll on different elements, `document.scrollingElement` exists so the browser can tell us what to use for scrolling to anchors work for all modern browsers. Since `document.scrollingElement` is undefined in older browsers, `document.body` is available as fallback mobile scrolling element.pull/821/head
parent
2ec5018bff
commit
3a446f1f9d
Loading…
Reference in new issue