code: function resizeScrollbar() {
        var contentSize = $contentEl[sizeAttr]();
        var scrollOffset = $scrollContentEl[scrollOffsetAttr](); // Either scrollTop() or scrollLeft().
        var scrollbarSize = $scrollbarEl[sizeAttr]();
        var scrollbarRatio = scrollbarSize / contentSize;
  
        // Calculate new height/position of drag handle.
        // Offset of 2px allows for a small top/bottom or left/right margin around handle.
        var handleOffset = Math.round(scrollbarRatio * scrollOffset) + 2;
        var handleSize = Math.floor(scrollbarRatio * (scrollbarSize - 2)) - 2;
  
        if (scrollbarSize < contentSize) {
          if (scrollDirection === 'vert'){
            $dragHandleEl.css({'top': handleOffset, 'height': handleSize});
          } else {
            $dragHandleEl.css({'left': handleOffset, 'width': handleSize});
          }
          $scrollbarEl.show();
        } else {
           $scrollbarEl.hide();
        }
      }
docs: Resize scrollbar