Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scrollview触摸锁死的BUG #1829

Open
iNeverSleeeeep opened this issue Apr 16, 2016 · 0 comments
Open

scrollview触摸锁死的BUG #1829

iNeverSleeeeep opened this issue Apr 16, 2016 · 0 comments

Comments

@iNeverSleeeeep
Copy link

如果scrollview在moving的过程中visible从true变为false, 会导致onTouchEnded和onTouchCanceled不能正确结束,_touchMoved一直为true。触摸就被锁死了。附上简单的代码。
`

bool ScrollView::onTouchBegan(Touch* touch, Event* event)
{
   if (_touches.size() > 2 ||
            _touchMoved          ||
            !frame.containsPoint(touch->getLocation()))
        {
            return false;
        }
}

void ScrollView::onTouchMoved(Touch* touch, Event* event)
{
    _touchMoved = true;
}

void ScrollView::onTouchEnded(Touch* touch, Event* event)
{
    if (!this->isVisible())
    {
        return; //----------->在这返回了
    }

    auto touchIter = std::find(_touches.begin(), _touches.end(), touch);

    if (touchIter != _touches.end())
    {
        if (_touches.size() == 1 && _touchMoved)
        {
            this->schedule(CC_SCHEDULE_SELECTOR(ScrollView::deaccelerateScrolling));
        }
        _touches.erase(touchIter);
    } 

    if (_touches.size() == 0)
    {
        _dragging = false;    
        _touchMoved = false;
    }
}

void ScrollView::onTouchCancelled(Touch* touch, Event* event)
{
    if (!this->isVisible())
    {
        return; //----------->在这返回了
    }

    auto touchIter = std::find(_touches.begin(), _touches.end(), touch);
    _touches.erase(touchIter);

    if (_touches.size() == 0)
    {
        _dragging = false;    
        _touchMoved = false;
    }
}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant