Open icoloma opened 10 years ago
In pseudo code, we could add something like this at the beginning of function
if element is document.body then animatedScrollTo(document.documentElement, samePosition, sameTime)
With that change we will be animating both properties at same time for compatibility and user of library will be still using just document.body
to initialize animation (just like in the example)
That means calling everything twice, including requestAnimationFrame
. In my head, it makes more sense to also accept an array of values and in that case iterate the values. Change the recommendation to use [ document.body, document.documentElement ] and it's done.
Added a pull request that detects document.body & document.documentElement So it adds support for Firefox and IE.
PR: #9
+1
Firefox will not scroll on
body
but onhtml
: http://stackoverflow.com/questions/12222485/why-to-use-html-body-for-scrolltop-instead-of-just-htmlWith the current code examples it's impossible to know which one to use, and one has to correct that manually.