diff --git a/src/browser-scripts/scroll.ts b/src/browser-scripts/scroll.ts index 2dd791a..80c6a11 100644 --- a/src/browser-scripts/scroll.ts +++ b/src/browser-scripts/scroll.ts @@ -14,9 +14,14 @@ export function scrollAction( if (!element) { throw new Error('Element ' + selector + ' has not been found at the page'); } - if (!['auto', 'scroll'].includes(getComputedStyle(element).overflow) && element !== document.documentElement) { + + const overflowDirection = + action === 'scrollToOffset' ? 'overflow' : action === 'scrollToBottom' ? 'overflowY' : 'overflowX'; + const overflowStyles = getComputedStyle(element)[overflowDirection].split(' '); + if (!overflowStyles.includes('auto') && !overflowStyles.includes('scroll') && element !== document.documentElement) { throw new Error('Element ' + selector + ' is not scrollable'); } + switch (action) { case 'scrollToOffset': if (!offset) {