Skip to content

Commit

Permalink
chore: Extend overflow detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Al-Dani committed Dec 13, 2024
1 parent 0017ff3 commit 36df5ff
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/browser-scripts/scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 36df5ff

Please sign in to comment.