Skip to main content

scrollIntoView

Scroll element into viewport (MDN Reference).

Usage
$(selector).scrollIntoView(scrollIntoViewOptions)
Parameters
NameTypeDetails
scrollIntoViewOptionsobject, booleanoptions for Element.scrollIntoView() (default: { block: 'start', inline: 'nearest' })
Example
scrollIntoView.js
it('should demonstrate the scrollIntoView command', async () => {
const elem = await $('#myElement');
// scroll to specific element
await elem.scrollIntoView();
// center element within the viewport
await elem.scrollIntoView({ block: 'center', inline: 'center' });
});