Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document.body no longer seems to work on Chrome & firefox. #19

Open
moehammoud opened this issue Sep 8, 2017 · 2 comments
Open

document.body no longer seems to work on Chrome & firefox. #19

moehammoud opened this issue Sep 8, 2017 · 2 comments

Comments

@moehammoud
Copy link

So it seems that using the element document.body no longer works on Chrome and Firefox. It still works just fine on Safari and IE.
The fix for Chrome seems to be using document.documentElement instead of document.body. The issue now is that the fix no longer works in Safari. I can include a simple if else statement to ensure each browser has a valid animatedScrollTo function called, but I wonder if there is a more elegant solution that could be used or included in the animatedScrollTo library.

Example of my animateScrollTo call after syntax change.

animatedScrollTo(
      document.documentElement,
      el.offsetTop,
      500,
      function(){console.log("animateScroll fired")}
    );
@alexjfno1
Copy link

+1 I have the same issue.

@danilostrazzullo
Copy link

danilostrazzullo commented Oct 16, 2017

Probably the "future-proof" fix could be using document.scrollingElement.
Currently it works fine in every modern desktop browser (but it's NOT supported in IE <= 11).
For more details take a look to the related browser compatibility table on MDN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants