function getScrollableDistances() {
      var scrollTop = typeof(window.pageYOffset) == 'number' ?
          window.pageYOffset : document.documentElement.scrollTop;
      var scrollLeft = typeof(window.pageXOffset) == 'number' ?
          window.pageXOffset : document.documentElement.scrollLeft;
      return [
          Math.max(scrollTop - containerDimensions.top, 0), 
          Math.max(
              containerDimensions.left + containerDimensions.width
              - scrollLeft - width, 0),
          Math.max(
              containerDimensions.top + containerDimensions.height
              - scrollTop - height, 0),
          Math.max(scrollLeft - containerDimensions.left, 0)];
    }
Returns the available distance the scrolling viewport can still be
scrolled before reaching the selection container margins: even if the
document could scroll further past the selection container margins,
dragging the selection box does not cause further scrolling once the
selection container margins are in view.

@return {!Array.<number>} Available scrolling distances (in px),
    respectively from the following margins: top, right, bottom, left.