function _calcBounds(size, scrollOffset) {

        // Local data
        var prevHeight = this._calcScrollHeight(false);
        var nextHeight = this._calcScrollHeight(true);
        var enforeMinSize = _isSequentiallyScrollingOptimized.call(this);

        // 1. When the rendered height is smaller than the total height,
        //    then lock to the primary bounds
        var totalHeight;
        if (enforeMinSize) {
            if ((nextHeight !== undefined) && (prevHeight !== undefined)) {
                totalHeight = prevHeight + nextHeight;
            }
            if ((totalHeight !== undefined) && (totalHeight <= size[this._direction])) {
                this._scroll.boundsReached = Bounds.BOTH;
                this._scroll.springPosition = this.options.alignment ? -nextHeight : prevHeight;
                this._scroll.springSource = SpringSource.MINSIZE;
                return;
            }
        }
        totalHeight = (prevHeight || 0) + (nextHeight || 0);

        // 2. Check whether primary boundary has been reached
        if (this.options.alignment) {
            if (enforeMinSize) {
                if ((nextHeight !== undefined) && ((scrollOffset + nextHeight) <= 0)) {
                    this._scroll.boundsReached = Bounds.NEXT;
                    this._scroll.springPosition = -nextHeight;
                    this._scroll.springSource = SpringSource.NEXTBOUNDS;
                    return;
                }
            }
            else {
                var firstPrevItemHeight = this._calcScrollHeight(false, true);
                if ((nextHeight !== undefined) && firstPrevItemHeight && ((scrollOffset + nextHeight + size[this._direction]) <= firstPrevItemHeight)) {
                    this._scroll.boundsReached = Bounds.NEXT;
                    this._scroll.springPosition = nextHeight - (size[this._direction] - firstPrevItemHeight);
                    this._scroll.springSource = SpringSource.NEXTBOUNDS;
                    return;
                }
            }
        }
        else {
            if ((prevHeight !== undefined) && ((scrollOffset - prevHeight) >= 0)) {
                this._scroll.boundsReached = Bounds.PREV;
                this._scroll.springPosition = prevHeight;
                this._scroll.springSource = SpringSource.PREVBOUNDS;
                return;
            }
        }

        // 3. Check if secondary bounds has been reached
        if (this.options.alignment) {
            if ((prevHeight !== undefined) && (totalHeight > size[this._direction]) && ((scrollOffset - prevHeight) >= -size[this._direction])) {
                this._scroll.boundsReached = Bounds.PREV;
                this._scroll.springPosition = -size[this._direction] + prevHeight;
                this._scroll.springSource = SpringSource.PREVBOUNDS;
                return;
            }
        }
        else {
            var nextBounds = enforeMinSize ? size[this._direction] : this._calcScrollHeight(true, true);
            if ((nextHeight !== undefined) && ((scrollOffset + nextHeight) <= nextBounds)){
                this._scroll.boundsReached = Bounds.NEXT;
                this._scroll.springPosition = nextBounds - nextHeight;
                this._scroll.springSource = SpringSource.NEXTBOUNDS;
                return;
            }
        }

        // No bounds reached
        this._scroll.boundsReached = Bounds.NONE;
        this._scroll.springPosition = undefined;
        this._scroll.springSource = SpringSource.NONE;
    }
function _calcBounds(size, scrollOffset) {

        
        var prevHeight = this._calcScrollHeight(false);
        var nextHeight = this._calcScrollHeight(true);
        var enforeMinSize = _isSequentiallyScrollingOptimized.call(this);

        
        
        var totalHeight;
        if (enforeMinSize) {
            if ((nextHeight !== undefined) && (prevHeight !== undefined)) {
                totalHeight = prevHeight + nextHeight;
            }
            if ((totalHeight !== undefined) && (totalHeight <= size[this._direction])) {
                this._scroll.boundsReached = Bounds.BOTH;
                this._scroll.springPosition = this.options.alignment ? -nextHeight : prevHeight;
                this._scroll.springSource = SpringSource.MINSIZE;
                return;
            }
        }
        totalHeight = (prevHeight || 0) + (nextHeight || 0);

        
        if (this.options.alignment) {
            if (enforeMinSize) {
                if ((nextHeight !== undefined) && ((scrollOffset + nextHeight) <= 0)) {
                    this._scroll.boundsReached = Bounds.NEXT;
                    this._scroll.springPosition = -nextHeight;
                    this._scroll.springSource = SpringSource.NEXTBOUNDS;
                    return;
                }
            }
            else {
                var firstPrevItemHeight = this._calcScrollHeight(false, true);
                if ((nextHeight !== undefined) && firstPrevItemHeight && ((scrollOffset + nextHeight + size[this._direction]) <= firstPrevItemHeight)) {
                    this._scroll.boundsReached = Bounds.NEXT;
                    this._scroll.springPosition = nextHeight - (size[this._direction] - firstPrevItemHeight);
                    this._scroll.springSource = SpringSource.NEXTBOUNDS;
                    return;
                }
            }
        }
        else {
            if ((prevHeight !== undefined) && ((scrollOffset - prevHeight) >= 0)) {
                this._scroll.boundsReached = Bounds.PREV;
                this._scroll.springPosition = prevHeight;
                this._scroll.springSource = SpringSource.PREVBOUNDS;
                return;
            }
        }

        
        if (this.options.alignment) {
            if ((prevHeight !== undefined) && (totalHeight > size[this._direction]) && ((scrollOffset - prevHeight) >= -size[this._direction])) {
                this._scroll.boundsReached = Bounds.PREV;
                this._scroll.springPosition = -size[this._direction] + prevHeight;
                this._scroll.springSource = SpringSource.PREVBOUNDS;
                return;
            }
        }
        else {
            var nextBounds = enforeMinSize ? size[this._direction] : this._calcScrollHeight(true, true);
            if ((nextHeight !== undefined) && ((scrollOffset + nextHeight) <= nextBounds)){
                this._scroll.boundsReached = Bounds.NEXT;
                this._scroll.springPosition = nextBounds - nextHeight;
                this._scroll.springSource = SpringSource.NEXTBOUNDS;
                return;
            }
        }

        
        this._scroll.boundsReached = Bounds.NONE;
        this._scroll.springPosition = undefined;
        this._scroll.springSource = SpringSource.NONE;
    }
function _calcBounds ( size , scrollOffset ) { // Local data var prevHeight = this . _calcScrollHeight ( false ) ; var nextHeight = this . _calcScrollHeight ( true ) ; var enforeMinSize = _isSequentiallyScrollingOptimized . call ( this ) ; // 1. When the rendered height is smaller than the total height, //    then lock to the primary bounds var totalHeight ; if ( enforeMinSize ) { if ( ( nextHeight !== undefined ) && ( prevHeight !== undefined ) ) { totalHeight = prevHeight + nextHeight ; } if ( ( totalHeight !== undefined ) && ( totalHeight <= size [ this . _direction ] ) ) { this . _scroll . boundsReached = Bounds . BOTH ; this . _scroll . springPosition = this . options . alignment ? - nextHeight : prevHeight ; this . _scroll . springSource = SpringSource . MINSIZE ; return ; } } totalHeight = ( prevHeight || 0 ) + ( nextHeight || 0 ) ; // 2. Check whether primary boundary has been reached if ( this . options . alignment ) { if ( enforeMinSize ) { if ( ( nextHeight !== undefined ) && ( ( scrollOffset + nextHeight ) <= 0 ) ) { this . _scroll . boundsReached = Bounds . NEXT ; this . _scroll . springPosition = - nextHeight ; this . _scroll . springSource = SpringSource . NEXTBOUNDS ; return ; } } else { var firstPrevItemHeight = this . _calcScrollHeight ( false , true ) ; if ( ( nextHeight !== undefined ) && firstPrevItemHeight && ( ( scrollOffset + nextHeight + size [ this . _direction ] ) <= firstPrevItemHeight ) ) { this . _scroll . boundsReached = Bounds . NEXT ; this . _scroll . springPosition = nextHeight - ( size [ this . _direction ] - firstPrevItemHeight ) ; this . _scroll . springSource = SpringSource . NEXTBOUNDS ; return ; } } } else { if ( ( prevHeight !== undefined ) && ( ( scrollOffset - prevHeight ) >= 0 ) ) { this . _scroll . boundsReached = Bounds . PREV ; this . _scroll . springPosition = prevHeight ; this . _scroll . springSource = SpringSource . PREVBOUNDS ; return ; } } // 3. Check if secondary bounds has been reached if ( this . options . alignment ) { if ( ( prevHeight !== undefined ) && ( totalHeight > size [ this . _direction ] ) && ( ( scrollOffset - prevHeight ) >= - size [ this . _direction ] ) ) { this . _scroll . boundsReached = Bounds . PREV ; this . _scroll . springPosition = - size [ this . _direction ] + prevHeight ; this . _scroll . springSource = SpringSource . PREVBOUNDS ; return ; } } else { var nextBounds = enforeMinSize ? size [ this . _direction ] : this . _calcScrollHeight ( true , true ) ; if ( ( nextHeight !== undefined ) && ( ( scrollOffset + nextHeight ) <= nextBounds ) ) { this . _scroll . boundsReached = Bounds . NEXT ; this . _scroll . springPosition = nextBounds - nextHeight ; this . _scroll . springSource = SpringSource . NEXTBOUNDS ; return ; } } // No bounds reached this . _scroll . boundsReached = Bounds . NONE ; this . _scroll . springPosition = undefined ; this . _scroll . springSource = SpringSource . NONE ; }
Calculates the scroll boundaries and sets the spring accordingly.
Calculates the scroll boundaries and sets the spring accordingly .