src/aria/utils/Dom.js
function (position, size, base) {
            var viewportSize = this._getViewportSize();
            var documentScroll = this._getDocumentScroll(base);

            var minTopValue = documentScroll.scrollTop;
            var maxTopValue = Math.max(0, documentScroll.scrollTop + viewportSize.height - size.height);
            var top = aria.utils.Math.normalize(position.top, minTopValue, maxTopValue);

            var minLeftValue = documentScroll.scrollLeft;
            var maxLeftValue = Math.max(0, documentScroll.scrollLeft + viewportSize.width - size.width);
            var left = aria.utils.Math.normalize(position.left, minLeftValue, maxLeftValue);

            return {
                'top' : top,
                'left' : left
            };
        }
function (position, size, base) {
            var viewportSize = this._getViewportSize();
            var documentScroll = this._getDocumentScroll(base);

            var minTopValue = documentScroll.scrollTop;
            var maxTopValue = Math.max(0, documentScroll.scrollTop + viewportSize.height - size.height);
            var top = aria.utils.Math.normalize(position.top, minTopValue, maxTopValue);

            var minLeftValue = documentScroll.scrollLeft;
            var maxLeftValue = Math.max(0, documentScroll.scrollLeft + viewportSize.width - size.width);
            var left = aria.utils.Math.normalize(position.left, minLeftValue, maxLeftValue);

            return {
                'top' : top,
                'left' : left
            };
        }
function ( position , size , base ) { var viewportSize = this . _getViewportSize ( ) ; var documentScroll = this . _getDocumentScroll ( base ) ; var minTopValue = documentScroll . scrollTop ; var maxTopValue = Math . max ( 0 , documentScroll . scrollTop + viewportSize . height - size . height ) ; var top = aria . utils . Math . normalize ( position . top , minTopValue , maxTopValue ) ; var minLeftValue = documentScroll . scrollLeft ; var maxLeftValue = Math . max ( 0 , documentScroll . scrollLeft + viewportSize . width - size . width ) ; var left = aria . utils . Math . normalize ( position . left , minLeftValue , maxLeftValue ) ; return { 'top' : top , 'left' : left } ; }
Given a position + size couple, return a corrected position that should fit in the viewport. If the size is
bigger than the vieport it returns a position such that the top left corner of the element to be fit is in
the viewport.
@param {aria.utils.DomBeans:Position} position
@param {aria.utils.DomBeans:Size} size
@param {Object} base The base element used to account for scrolling offsets
@return {aria.utils.DomBeans:Position}
Given a position + size couple return a corrected position that should fit in the viewport . If the size is bigger than the vieport it returns a position such that the top left corner of the element to be fit is in the viewport .