Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,23 @@ export function getWin(ele: HTMLElement) {
*/
export function collectScroller(ele: HTMLElement) {
const scrollerList: HTMLElement[] = [];
let current = ele?.parentElement;
let current = ele?.parentNode;

const scrollStyle = ['hidden', 'scroll', 'clip', 'auto'];

while (current) {
const { overflowX, overflowY, overflow } =
getWin(current).getComputedStyle(current);
if ([overflowX, overflowY, overflow].some((o) => scrollStyle.includes(o))) {
scrollerList.push(current);
if (current instanceof HTMLElement) {
const { overflowX, overflowY, overflow } =
getWin(current).getComputedStyle(current);
if ([overflowX, overflowY, overflow].some((o) => scrollStyle.includes(o))) {
scrollerList.push(current);
}
} else if (current instanceof ShadowRoot) {
current = current.host;
continue;
}

current = current.parentElement;
current = current.parentNode;
}

return scrollerList;
Expand Down