From e4a35453aad470e2aec0fc9ff54c30f6cddc29c4 Mon Sep 17 00:00:00 2001 From: Alex Iglesias Date: Thu, 22 Apr 2021 12:50:21 +0200 Subject: [PATCH] Added isScrollable helper --- utils/helpers.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/utils/helpers.ts b/utils/helpers.ts index 7369fca..0dcdc55 100644 --- a/utils/helpers.ts +++ b/utils/helpers.ts @@ -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