我使用的是纯Polymer / Javascript,需要滚动到主面板底部。由于它是固定大小容器中的可滚动元素,因此typical JS answer

window.scrollTo(0,document.body.scrollHeight);


不起作用。

最佳答案

找不到直接的解决方案,所以自己发布答案。希望这可以帮助某人:)

Based on what I found here

//Get the main paper-drawer-panel element
    a = document.querySelector("paper-drawer-panel [main]")

//use the undocumented scroller property and set it to the scroller's height
    a.scroller.scrollTop = a.scroller.scrollHeight


更新:

我还发现,如果您在面板中选择任何元素或容器,则应该有附加的滚动方法,使您可以根据所选元素滚动到面板的顶部或底部。

//Get the main paper-drawer-panel element
    a = document.querySelector("some-element-container-in-paper-panel");
// Passing in false scrolls to the bottom of the container, no param to the top.
    a.scrollIntoView(false)

09-11 01:02
查看更多