var origMinX, origMinY, origMaxX, origMaxY;
origMinX = origMinY = 0;
origMaxX = viewport.width;
origMaxY = viewport.height;
if (container !== null) {
origMinX = container.left + offsets.container;
origMinY = container.top + offsets.container;
origMaxX = container.left + container.width - offsets.container;
origMaxY = container.top + container.height - offsets.container;
}
if (options.viewport === true) {
origMinX = Math.max(offsets.viewport, origMinX);
origMinY = Math.max(offsets.viewport, origMinY);
origMaxX = Math.min(viewport.width - offsets.viewport, origMaxX);
origMaxY = Math.min(viewport.height - offsets.viewport, origMaxY);
}
var maxBounds;
while (true) {
content = getContentSize(direction);
attemptDirection(direction);
maxBounds = calculateMaxPositions(direction, {
minX: origMinX,
minY: origMinY,
maxX: origMaxX,
maxY: origMaxY
});
compensateContainer(direction, maxBounds);
compensateViewport(direction, maxBounds);
if (_isPointInRange(pos, maxBounds)) {
compensateObstacles2(direction, maxBounds);
}
var box = $.extend({}, content, pos);