Material-design-lite: MDL breaks the scrollTop attribute

Created on 6 Nov 2015  路  4Comments  路  Source: google/material-design-lite

When using MDL, the scrollTop attribute of elements, e.g. the body, does not get updated and cannot be set. This breaks tools like Vimium that scroll the page for you.

You can test this on http://www.getmdl.io/started/. Scroll down the page a bit, open the console and enter

document.getElementsByTagName('body')[0].scrollTop

This will always return 0, even if you scrolled the body. If you try and enter that line on other pages, e.g. github, it will return a number indicating how far you have scrolled.

The same problem goes with setting the scrollTop attribute. It won't work on pages using MDL:

document.getElementsByTagName('body')[0].scrollTop = 50

But will work on other pages.

All 4 comments

This is a problem coming from how layout is done. Nothing we can do. The 2.X redactor should handle this and numerous other problems.

even one year later, scrollTop does not work, neither does the window.screenY property. My current workaround is recreating some of the styles with bootstrap while rebuilding the css from scratch

Instead of doing above do this document.getElementsByClassName('.mdl-layout__content')[0].scrollTop
Worked for me

Reference link : - https://stackoverflow.com/a/32037542/1280693

Was this page helpful?
0 / 5 - 0 ratings