code: function(pos, val) {
  
              var overlayEl = this.element,
  
                  buffer = Overlay.VIEWPORT_OFFSET,
  
                  x = (pos == "x"),
  
                  overlaySize      = (x) ? overlayEl.offsetWidth : overlayEl.offsetHeight,
                  viewportSize     = (x) ? Dom.getViewportWidth() : Dom.getViewportHeight(),
                  docScroll        = (x) ? Dom.getDocumentScrollLeft() : Dom.getDocumentScrollTop(),
                  overlapPositions = (x) ? Overlay.PREVENT_OVERLAP_X : Overlay.PREVENT_OVERLAP_Y,
  
                  context = this.cfg.getProperty("context"),
  
                  bOverlayFitsInViewport = (overlaySize + buffer < viewportSize),
                  bPreventContextOverlap = this.cfg.getProperty("preventcontextoverlap") && context && overlapPositions[(context[1] + context[2])],
  
                  minConstraint = docScroll + buffer,
                  maxConstraint = docScroll + viewportSize - overlaySize - buffer,
  
                  constrainedVal = val;
  
              if (val < minConstraint || val > maxConstraint) {
                  if (bPreventContextOverlap) {
                      constrainedVal = this._preventOverlap(pos, context[0], overlaySize, viewportSize, docScroll);
                  } else {
                      if (bOverlayFitsInViewport) {
                          if (val < minConstraint) {
                              constrainedVal = minConstraint;
                          } else if (val > maxConstraint) {
                              constrainedVal = maxConstraint;
                          }
                      } else {
                          constrainedVal = minConstraint;
                      }
                  }
              }
  
              return constrainedVal;
          }
docs: Shared implementation method for getConstrainedX and getConstrainedY.
  
  <p>
  Given a coordinate value, returns the calculated coordinate required to
  position the Overlay if it is to be constrained to the viewport, based on the
  current element size, viewport dimensions, scroll values and preventoverlap
  settings
  </p>
  
  @method _getConstrainedPos
  @protected
  @param {String} pos The coordinate which needs to be constrained, either "x" or "y"
  @param {Number} The coordinate value which needs to be constrained
  @return {Number} The constrained coordinate value