댓글 검색 목록

[javascript] 요소가 스크롤 가능한지 확인 (10/86)

페이지 정보

작성자 운영자 작성일 20-03-31 16:10 조회 890 댓글 0

ele 요소가 스크롤 가능한 경우 다음 함수는 true를 리턴합니다.


https://htmldom.dev/check-if-an-element-is-scrollable 



const isScrollable = function(ele) {
    // Compare the height to see if the element has scrollable content
    const hasScrollableContent = ele.scrollHeight > ele.clientHeight;

    // It's not enough because the element's `overflow-y` style can be set as
    // * `hidden`
    // * `hidden !important`
    // In those cases, the scrollbar isn't shown
    const overflowYStyle = window.getComputedStyle(ele).overflowY;
    const isOverflowHidden = overflowYStyle.indexOf('hidden') !== -1;

    return hasScrollableContent && !isOverflowHidden;
};





댓글목록 0

등록된 댓글이 없습니다.

웹학교 로고

온라인 코딩학교

코리아뉴스 2001 - , All right reserved.