void ScrollView::handleReleaseLogic(Touch *touch)
{
    // Gather the last touch information when released
    {
        Vec3 currPt, prevPt;
        if(calculateCurrAndPrevTouchPoints(touch, &currPt, &prevPt))
        {
            Vec3 delta3 = currPt - prevPt;
            Vec2 delta(delta3.x, delta3.y);
            gatherTouchMove(delta);
        }
    }

    _bePressed = false;

    bool bounceBackStarted = startBounceBackIfNeeded();
    if(!bounceBackStarted && _inertiaScrollEnabled)
    {
        Vec2 touchMoveVelocity = calculateTouchMoveVelocity();
        if(touchMoveVelocity != Vec2::ZERO)
        {
            startInertiaScroll(touchMoveVelocity);
        }
    }

    if(_verticalScrollBar != nullptr)
    {
        _verticalScrollBar->onTouchEnded();
    }
    if(_horizontalScrollBar != nullptr)
    {
        _horizontalScrollBar->onTouchEnded();
    }
}
Esempio n. 2
0
void ScrollView::handleMoveLogic(Touch *touch)
{
    Vec3 currPt, prevPt;
    if(!calculateCurrAndPrevTouchPoints(touch, &currPt, &prevPt))
    {
        return;
    }
    Vec3 delta3 = currPt - prevPt;
    Vec2 delta(delta3.x, delta3.y);
    scrollChildren(delta);
    
    // Gather touch move information for speed calculation
    gatherTouchMove(delta);
}