madebysource / animated-scrollto

Animated scrolling without any dependency on libraries
MIT License
319 stars 57 forks source link

Scrolling is not working on Firefox #4

Open icoloma opened 10 years ago

icoloma commented 10 years ago

Firefox will not scroll on body but on html: http://stackoverflow.com/questions/12222485/why-to-use-html-body-for-scrolltop-instead-of-just-html

With the current code examples it's impossible to know which one to use, and one has to correct that manually.

marekhrabe commented 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)

icoloma commented 10 years ago

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.

gijsroge commented 9 years ago

Added a pull request that detects document.body & document.documentElement So it adds support for Firefox and IE.

PR: #9

nikoloza commented 7 years ago

+1