1

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. 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?

Here is the element on webcomponents.org.

Let Me Tink About It
  • 15,156
  • 21
  • 98
  • 207

1 Answers1

0

Instead of scroll-target-behavior, I'm just using the platform and going with: scrollIntoView(). Documentation

example
const element = document.getElementById("box");

element.scrollIntoView();
element.scrollIntoView(false);
element.scrollIntoView({block: "end"});
element.scrollIntoView({behavior: "instant", block: "end", inline: "nearest"});

Or, to scroll to the top of the page:

document.body.scrollIntoView({
  behavior: "smooth",
  block: "top",
})
Let Me Tink About It
  • 15,156
  • 21
  • 98
  • 207