Skip to main content
Use this API to scroll the page to a specific position.

Parameters

PropertyTypeRequiredDescription
scrollTopNumberNoTarget scroll position in pixels
durationNumberNoScroll animation duration in ms (default: 300)
selectorStringNoCSS selector to scroll to
successFunctionNoCallback on success
failFunctionNoCallback on failure
completeFunctionNoCallback that always executes

Code Example

// Scroll to top
my.pageScrollTo({
  scrollTop: 0,
  duration: 300
});

// Scroll to element
my.pageScrollTo({
  selector: '#target-element'
});

my.createSelectorQuery

Query DOM elements