diff --git a/packages/page-controller/src/actions.ts b/packages/page-controller/src/actions.ts index 7ac96e7..04ee721 100644 --- a/packages/page-controller/src/actions.ts +++ b/packages/page-controller/src/actions.ts @@ -287,7 +287,10 @@ export async function scrollVertically(scroll_amount: number, element?: HTMLElem while (currentElement && attempts < 10) { const computedStyle = window.getComputedStyle(currentElement) - const hasScrollableY = /(auto|scroll|overlay)/.test(computedStyle.overflowY) + const hasScrollableY = + /(auto|scroll|overlay)/.test(computedStyle.overflowY) || + (computedStyle.scrollbarWidth && computedStyle.scrollbarWidth !== 'auto') || + (computedStyle.scrollbarGutter && computedStyle.scrollbarGutter !== 'auto') const canScrollVertically = currentElement.scrollHeight > currentElement.clientHeight if (hasScrollableY && canScrollVertically) { @@ -426,7 +429,10 @@ export async function scrollHorizontally(scroll_amount: number, element?: HTMLEl while (currentElement && attempts < 10) { const computedStyle = window.getComputedStyle(currentElement) - const hasScrollableX = /(auto|scroll|overlay)/.test(computedStyle.overflowX) + const hasScrollableX = + /(auto|scroll|overlay)/.test(computedStyle.overflowX) || + (computedStyle.scrollbarWidth && computedStyle.scrollbarWidth !== 'auto') || + (computedStyle.scrollbarGutter && computedStyle.scrollbarGutter !== 'auto') const canScrollHorizontally = currentElement.scrollWidth > currentElement.clientWidth if (hasScrollableX && canScrollHorizontally) { diff --git a/packages/page-controller/src/dom/dom_tree/index.js b/packages/page-controller/src/dom/dom_tree/index.js index 9f65ab7..2f12ee1 100644 --- a/packages/page-controller/src/dom/dom_tree/index.js +++ b/packages/page-controller/src/dom/dom_tree/index.js @@ -503,11 +503,16 @@ export default ( const overflowX = style.overflowX const overflowY = style.overflowY - // Check scrollable distances + // scrollbar-width/scrollbar-gutter are only set on elements designed to scroll; + // their presence signals scroll intent even when overflow is hidden (e.g. overflow: auto on :hover) + const hasScrollbarSignal = + (style.scrollbarWidth && style.scrollbarWidth !== 'auto') || + (style.scrollbarGutter && style.scrollbarGutter !== 'auto') + const scrollableX = overflowX === 'auto' || overflowX === 'scroll' const scrollableY = overflowY === 'auto' || overflowY === 'scroll' - if (!scrollableX && !scrollableY) { + if (!scrollableX && !scrollableY && !hasScrollbarSignal) { return null // Not scrollable in any direction } @@ -521,11 +526,11 @@ export default ( return null // Not scrollable } - if (!scrollableY && scrollWidth < threshold) { + if (!scrollableY && !hasScrollbarSignal && scrollWidth < threshold) { return null // Not scrollable horizontally } - if (!scrollableX && scrollHeight < threshold) { + if (!scrollableX && !hasScrollbarSignal && scrollHeight < threshold) { return null // Not scrollable vertically } @@ -547,6 +552,8 @@ export default ( scrollData: scrollData, }) + console.log('scrollData!!!', scrollData) + return scrollData }