scrollIntoView
将元素滚动到视口(MDN 参考)。
用法
$(selector).scrollIntoView(scrollIntoViewOptions)
参数
名称 | 类型 | 详情 |
---|---|---|
scrollIntoViewOptions | object , boolean | Element.scrollIntoView() 的选项(默认:{ block: 'start', inline: 'nearest' } ) |
示例
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' });
});