Skip to content

Instantly share code, notes, and snippets.

Revisions

  1. jlbruno created this gist Jul 22, 2011.
    18 changes: 18 additions & 0 deletions isItScrollableWithoutVisibleScrollbars.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    var isItScrollableWithoutVisibleScrollbars = function(el) {
    if (el === null) {
    return false;
    }
    var isScrollable = false;
    var hasScrollbars = false;
    // first, lets find out if it has scrollable content
    isScrollable = el.scrollHeight > el.offsetHeight ? true : false;
    // if it's scrollable, let's see if it likely has scrollbars
    if (isScrollable) {
    hasScrollbars = (el.offsetWidth > el.scrollWidth) ? true : false;
    }
    if (isScrollable && !hasScrollbars) {
    return true;
    } else {
    return false;
    }
    };
    5 changes: 5 additions & 0 deletions test.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    // example usage

    if ( isItScrollableWithoutVisibleScrollbars(plwrap) ) {
    playlistScroll = new iScroll('playlist');
    }