Questions tagged [js-scrollto]

The Window.scrollTo() method scrolls to a particular set of coordinates in the document.

The Window.scrollTo() and Window.scroll() methods scroll to a particular set of coordinates in the document.

Syntax

window.scrollTo(x-coord, y-coord)
window.scrollTo(options)
window.scroll(x-coord, y-coord)
window.scroll(options)

Parameters

  • x-coord is the pixel along the horizontal axis of the document that you want displayed in the upper left.
  • y-coord is the pixel along the vertical axis of the document that you want displayed in the upper left.
  • options is a ScrollToOptions dictionary.

Examples

window.scrollTo(0, 1000);
window.scrollTo(0, -1000);
window.scroll(0, 1000);
window.scroll(0, -1000);

Reference

18 questions
14
votes
2 answers

What is the difference between the different scroll options?

I have tried a few ways of adding scrolling to tables, but just one of them works correctly. What is the difference between them? First: JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("arguments[0].scrollIntoView();",…
6
votes
2 answers

Lazy loading conflicting with ScrollTo anchor to ID scroll - Stops halfway through the page

I have a scrollTo function on my page where when you click on a specific button you scroll to a section with a unique ID. The problem is I am using lazy loading for the images on my website so, this will cause the ScrollTo to stop halfway through…
Galanthus
  • 1,958
  • 3
  • 14
  • 35
6
votes
0 answers

Using Intersection Observer to check if an element is fully visible on browser viewport

After a page loads, I’d like to observe an element (addonCard) using the Intersection Observer API to know if that element is fully visible or not. If the element is invisible or partially visible, I want the element to be scrolled into full…
6
votes
1 answer

ScrollTo not working with scroll-snap and 100vh container

When I have a .sections container with several .section elements inside, and setup scroll-snap, it will ONLY work if I give the section a fixed height of 100vh. Without the height, the scroll-snap will not work. This is fine, except without the…
Jeremy Harris
  • 24,318
  • 13
  • 79
  • 133
3
votes
1 answer

window.scrollTo issue with position fixed menu

I'm looking for some help about a fixed position menu on my project. When I'm scrolling down, my click events don't work anymore. Instead of scrolling smoothly in the right section, my menu is repositioned on top after clicking on the links. For…
fitous
  • 33
  • 4
3
votes
2 answers

Vue Scroll to top on pageload

I'm currently using Gridsome in my portfolio website. But when I'm on the bottom of a page on a mobile/tablet device that is longer then the page I'm navigating to, the page doesn't scroll to the top on Firefox. On Google Chrome it works fine. I'm…
2
votes
1 answer

How to scroll to a Ref within a modal scree in react

I currently have multiple components within a bootstrap modal. My goal is to be able to do a window.scroll to a given component following a user action. Basically, this is what I have tried: class App extends Component { constructor (props) { …
Rayan Ahmed
  • 165
  • 2
  • 11
1
vote
1 answer

How to scroll to element in v-if with VueJS?

In my Vue 3 project, I have this button in a component: