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' });
});