src/aria/utils/Dom.js
function (geometry, container) {
            geometry.width = geometry.width || 0;
            geometry.height = geometry.height || 0;
            if (container == this.VIEWPORT) {
                container = this.getViewportSize();
                container.x = container.y = 0;
            }
            container.width = container.width || 0;
            container.height = container.height || 0;
            var left = (geometry.x < container.x) ? container.x : geometry.x;
            var top = (geometry.y < container.y) ? container.y : geometry.y;
            if (geometry.x + geometry.width > container.x + container.width) {
                left = container.x + container.width - geometry.width;
            }
            if (geometry.y + geometry.height > container.y + container.height) {
                top = container.y + container.height - geometry.height;
            }
            return {
                'top' : top,
                'left' : left
            };

        }
function (geometry, container) {
            geometry.width = geometry.width || 0;
            geometry.height = geometry.height || 0;
            if (container == this.VIEWPORT) {
                container = this.getViewportSize();
                container.x = container.y = 0;
            }
            container.width = container.width || 0;
            container.height = container.height || 0;
            var left = (geometry.x < container.x) ? container.x : geometry.x;
            var top = (geometry.y < container.y) ? container.y : geometry.y;
            if (geometry.x + geometry.width > container.x + container.width) {
                left = container.x + container.width - geometry.width;
            }
            if (geometry.y + geometry.height > container.y + container.height) {
                top = container.y + container.height - geometry.height;
            }
            return {
                'top' : top,
                'left' : left
            };

        }
function ( geometry , container ) { geometry . width = geometry . width || 0 ; geometry . height = geometry . height || 0 ; if ( container == this . VIEWPORT ) { container = this . getViewportSize ( ) ; container . x = container . y = 0 ; } container . width = container . width || 0 ; container . height = container . height || 0 ; var left = ( geometry . x < container . x ) ? container . x : geometry . x ; var top = ( geometry . y < container . y ) ? container . y : geometry . y ; if ( geometry . x + geometry . width > container . x + container . width ) { left = container . x + container . width - geometry . width ; } if ( geometry . y + geometry . height > container . y + container . height ) { top = container . y + container . height - geometry . height ; } return { 'top' : top , 'left' : left } ; }
Fits a geometry into another geometry
@param {aria.utils.DomBeans:Geometry} geometry
@param {aria.utils.DomBeans:Geometry|aria.utils.Dom:VIEWPORT:property} container
@return {aria.utils.DomBeans:Position} top and left values of the fitted geometry
Fits a geometry into another geometry