简体   繁体   English

聚合物2.x中铁滚动目标行为的演示

[英]Demo for iron-scroll-target-behavior in Polymer 2.x

I need to direct the browser to scroll to the top of the page. 我需要指示浏览器滚动到页面顶部。 I think iron-scroll-target-behavior might be a good choice. 我认为iron-scroll-target-behavior可能是一个不错的选择。 But I can't find any working demos. 但是我找不到任何有效的演示。

Can anyone locate or point me to a working demo of the iron-scroll-target-behavior element? 谁能找到我或将其指向iron-scroll-target-behavior元素的工作演示?

Here is the element on webcomponents.org. 这是webcomponents.org上的元素。

Instead of scroll-target-behavior , I'm just using the platform and going with: scrollIntoView() . 而不是scroll-target-behavior ,我只是在使用平台并使用: scrollIntoView() Documentation 文献资料

example
document.body.scrollIntoView({
  behavior: "smooth",
  block: "top",
})

Or, to scroll to the top of the page: 或者,滚动到页面顶部:

 document.body.scrollIntoView({ behavior: "smooth", block: "top", }) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM