Skip to content

Commit

Permalink
Added isScrollable helper
Browse files Browse the repository at this point in the history
  • Loading branch information
alexiglesias93 committed Apr 22, 2021
1 parent b1bae18 commit e4a3545
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
export const isVisible = (element: HTMLElement): boolean =>
!!(element.offsetWidth || element.offsetHeight || element.getClientRects().length);

/**
* Check if an element is scrollable
* @param element
* @returns {boolean}
*/
export const isScrollable = (element: Element): boolean => {
const { overflow } = getComputedStyle(element);
return overflow === 'auto' || overflow === 'scroll';
};

/**
* Find the first text node child of an element
* @param element
Expand Down

0 comments on commit e4a3545

Please sign in to comment.