Last active
September 30, 2021 09:26
-
-
Save manabuyasuda/2390f58d9fa51974c5dae94e4ddca5f6 to your computer and use it in GitHub Desktop.
要素が横スクロール可能な状態かを返します。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 要素が横スクロール可能な状態かを返します。 | |
| * @param {HTMLElement} element テーブルをスクロールしている親要素 | |
| * @return Boolean | |
| * @example | |
| * const tables = document.querySelectorAll('.table-wrap') | |
| * Array.from(tables).forEach((table) => { | |
| * canScrolled(table) ? canFunc() : notFunc() | |
| * }) | |
| */ | |
| const canScrolled = (element) => { | |
| const scrollWidth = element.scrollWidth | |
| const clientWidth = element.clientWidth | |
| const isScrolled = scrollWidth > clientWidth | |
| return isScrolled | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment