function _touchEnd(event) {

        // Remove touch
        var primaryTouch = this._scroll.activeTouches.length ? this._scroll.activeTouches[0] : undefined;
        for (var i = 0; i < event.changedTouches.length; i++) {
            var changedTouch = event.changedTouches[i];
            for (var j = 0; j < this._scroll.activeTouches.length; j++) {
                var touch = this._scroll.activeTouches[j];
                if (touch.id === changedTouch.identifier) {

                    // Remove touch from active-touches
                    this._scroll.activeTouches.splice(j, 1);

                    // When a different touch now becomes the primary touch, update
                    // its start position to match the current move offset.
                    if ((j === 0) && this._scroll.activeTouches.length) {
                        var newPrimaryTouch = this._scroll.activeTouches[0];
                        newPrimaryTouch.start[0] = newPrimaryTouch.current[0] - (touch.current[0] - touch.start[0]);
                        newPrimaryTouch.start[1] = newPrimaryTouch.current[1] - (touch.current[1] - touch.start[1]);
                    }
                    break;
                }
            }
        }

        // Wait for all fingers to be released from the screen before resetting the move-spring
        if (!primaryTouch || this._scroll.activeTouches.length) {
            return;
        }

        // Determine velocity and add to particle
        var velocity = 0;
        var diffTime = primaryTouch.time - primaryTouch.prevTime;
        if ((diffTime > 0) && ((_getEventTimestamp(event) - primaryTouch.time) <= this.options.touchMoveNoVelocityDuration)) {
            var diffOffset = primaryTouch.current[this._direction] - primaryTouch.prev[this._direction];
            velocity = diffOffset / diffTime;
        }

        // Release scroll force
        var delta = this._scroll.touchDelta;
        var swipeDirection = (Math.abs(primaryTouch.current[0] - primaryTouch.prev[0]) > Math.abs(primaryTouch.current[1] - primaryTouch.prev[1])) ? 0 : 1;
        var allowSwipes = (swipeDirection === this._direction);
        this.releaseScrollForce(delta, velocity, allowSwipes);
        this._scroll.touchDelta = 0;
    }
function _touchEnd(event) {

        
        var primaryTouch = this._scroll.activeTouches.length ? this._scroll.activeTouches[0] : undefined;
        for (var i = 0; i < event.changedTouches.length; i++) {
            var changedTouch = event.changedTouches[i];
            for (var j = 0; j < this._scroll.activeTouches.length; j++) {
                var touch = this._scroll.activeTouches[j];
                if (touch.id === changedTouch.identifier) {

                    
                    this._scroll.activeTouches.splice(j, 1);

                    
                    
                    if ((j === 0) && this._scroll.activeTouches.length) {
                        var newPrimaryTouch = this._scroll.activeTouches[0];
                        newPrimaryTouch.start[0] = newPrimaryTouch.current[0] - (touch.current[0] - touch.start[0]);
                        newPrimaryTouch.start[1] = newPrimaryTouch.current[1] - (touch.current[1] - touch.start[1]);
                    }
                    break;
                }
            }
        }

        
        if (!primaryTouch || this._scroll.activeTouches.length) {
            return;
        }

        
        var velocity = 0;
        var diffTime = primaryTouch.time - primaryTouch.prevTime;
        if ((diffTime > 0) && ((_getEventTimestamp(event) - primaryTouch.time) <= this.options.touchMoveNoVelocityDuration)) {
            var diffOffset = primaryTouch.current[this._direction] - primaryTouch.prev[this._direction];
            velocity = diffOffset / diffTime;
        }

        
        var delta = this._scroll.touchDelta;
        var swipeDirection = (Math.abs(primaryTouch.current[0] - primaryTouch.prev[0]) > Math.abs(primaryTouch.current[1] - primaryTouch.prev[1])) ? 0 : 1;
        var allowSwipes = (swipeDirection === this._direction);
        this.releaseScrollForce(delta, velocity, allowSwipes);
        this._scroll.touchDelta = 0;
    }
function _touchEnd ( event ) { // Remove touch var primaryTouch = this . _scroll . activeTouches . length ? this . _scroll . activeTouches [ 0 ] : undefined ; for ( var i = 0 ; i < event . changedTouches . length ; i ++ ) { var changedTouch = event . changedTouches [ i ] ; for ( var j = 0 ; j < this . _scroll . activeTouches . length ; j ++ ) { var touch = this . _scroll . activeTouches [ j ] ; if ( touch . id === changedTouch . identifier ) { // Remove touch from active-touches this . _scroll . activeTouches . splice ( j , 1 ) ; // When a different touch now becomes the primary touch, update // its start position to match the current move offset. if ( ( j === 0 ) && this . _scroll . activeTouches . length ) { var newPrimaryTouch = this . _scroll . activeTouches [ 0 ] ; newPrimaryTouch . start [ 0 ] = newPrimaryTouch . current [ 0 ] - ( touch . current [ 0 ] - touch . start [ 0 ] ) ; newPrimaryTouch . start [ 1 ] = newPrimaryTouch . current [ 1 ] - ( touch . current [ 1 ] - touch . start [ 1 ] ) ; } break ; } } } // Wait for all fingers to be released from the screen before resetting the move-spring if ( ! primaryTouch || this . _scroll . activeTouches . length ) { return ; } // Determine velocity and add to particle var velocity = 0 ; var diffTime = primaryTouch . time - primaryTouch . prevTime ; if ( ( diffTime > 0 ) && ( ( _getEventTimestamp ( event ) - primaryTouch . time ) <= this . options . touchMoveNoVelocityDuration ) ) { var diffOffset = primaryTouch . current [ this . _direction ] - primaryTouch . prev [ this . _direction ] ; velocity = diffOffset / diffTime ; } // Release scroll force var delta = this . _scroll . touchDelta ; var swipeDirection = ( Math . abs ( primaryTouch . current [ 0 ] - primaryTouch . prev [ 0 ] ) > Math . abs ( primaryTouch . current [ 1 ] - primaryTouch . prev [ 1 ] ) ) ? 0 : 1 ; var allowSwipes = ( swipeDirection === this . _direction ) ; this . releaseScrollForce ( delta , velocity , allowSwipes ) ; this . _scroll . touchDelta = 0 ; }
Called whenever the user releases his fingers and the touch gesture
has completed. This will set the new position and if the user used a 'flick'
gesture give the scroll-offset particle a velocity and momentum into a
certain direction.
Called whenever the user releases his fingers and the touch gesture has completed . This will set the new position and if the user used a flick gesture give the scroll - offset particle a velocity and momentum into a certain direction .