Skip to content

Commit

Permalink
perf: update logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Wxh16144 committed Jul 21, 2023
1 parent df29585 commit 59e6cee
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/utils/domUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ export function scrollIntoView(
element: Maybe<Element>,
coverOptions?: boolean | ScrollIntoViewOptions
) {
let options: boolean | ScrollIntoViewOptions = { inline: 'nearest', block: 'nearest' };
if (typeof coverOptions === 'boolean') {
options = coverOptions;
} else if(typeof coverOptions === 'object') {
options = Object.assign(options, coverOptions);
if(element?.scrollIntoView) {
let options: typeof coverOptions = { inline: 'nearest', block: 'nearest' };
if (typeof coverOptions === 'boolean') {
options = coverOptions;
} else if(typeof coverOptions === 'object') {
options = Object.assign(options, coverOptions);
}
element.scrollIntoView(options);
}
element?.scrollIntoView(options);
}

0 comments on commit 59e6cee

Please sign in to comment.