Skip to content

Commit 59e6cee

Browse files
committed
perf: update logic
1 parent df29585 commit 59e6cee

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/utils/domUtils.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ export function scrollIntoView(
88
element: Maybe<Element>,
99
coverOptions?: boolean | ScrollIntoViewOptions
1010
) {
11-
let options: boolean | ScrollIntoViewOptions = { inline: 'nearest', block: 'nearest' };
12-
if (typeof coverOptions === 'boolean') {
13-
options = coverOptions;
14-
} else if(typeof coverOptions === 'object') {
15-
options = Object.assign(options, coverOptions);
11+
if(element?.scrollIntoView) {
12+
let options: typeof coverOptions = { inline: 'nearest', block: 'nearest' };
13+
if (typeof coverOptions === 'boolean') {
14+
options = coverOptions;
15+
} else if(typeof coverOptions === 'object') {
16+
options = Object.assign(options, coverOptions);
17+
}
18+
element.scrollIntoView(options);
1619
}
17-
element?.scrollIntoView(options);
1820
}

0 commit comments

Comments
 (0)