void ScrollView::jumpToBottomLeft() { if (_direction != Direction::BOTH) { CCLOG("Scroll direction is not both!"); return; } jumpToDestination(Vec2::ZERO); }
void ScrollView::jumpToTopLeft() { if (_direction != Direction::BOTH) { CCLOG("Scroll direction is not both!"); return; } jumpToDestination(Vec2(0.0f, _contentSize.height - _innerContainer->getContentSize().height)); }
void ScrollView::jumpToBottomRight() { if (_direction != Direction::BOTH) { CCLOG("Scroll direction is not both!"); return; } jumpToDestination(Vec2(_contentSize.width - _innerContainer->getContentSize().width, 0.0f)); }
void ScrollView::jumpToPercentBothDirection(const Vec2& percent) { if (_direction != Direction::BOTH) { return; } float minY = _contentSize.height - _innerContainer->getContentSize().height; float h = - minY; float w = _innerContainer->getContentSize().width - _contentSize.width; jumpToDestination(Vec2(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f)); }
void ScrollView::jumpToPercentVertical(float percent) { if (percent < 0.f) percent = 0.f; else if( percent > 100.f) percent = 100.f; float minY = _contentSize.height - _innerContainer->getContentSize().height; float h = - minY; jumpToDestination(Vec2(_innerContainer->getPosition().x, minY + percent * h / 100.0f)); }
void ListView::jumpToItem(ssize_t itemIndex, const Vec2& positionRatioInView, const Vec2& itemAnchorPoint) { Widget* item = getItem(itemIndex); if (item == nullptr) { return; } doLayout(); Vec2 destination = calculateItemDestination(positionRatioInView, item, itemAnchorPoint); if(!_bounceEnabled) { Vec2 delta = destination - getInnerContainerPosition(); Vec2 outOfBoundary = getHowMuchOutOfBoundary(delta); destination += outOfBoundary; } jumpToDestination(destination); }
void ScrollView::jumpToPercentHorizontal(float percent) { float w = _innerContainer->getContentSize().width - _contentSize.width; jumpToDestination(Vec2(-(percent * w / 100.0f), _innerContainer->getPosition().y)); }
void ScrollView::jumpToRight() { jumpToDestination(Vec2(_contentSize.width - _innerContainer->getContentSize().width, _innerContainer->getPosition().y)); }
void ScrollView::jumpToLeft() { jumpToDestination(Vec2(0.0f, _innerContainer->getPosition().y)); }
void ScrollView::jumpToTop() { jumpToDestination(Vec2(_innerContainer->getPosition().x, _contentSize.height - _innerContainer->getContentSize().height)); }
void ScrollView::jumpToBottom() { jumpToDestination(Vec2(_innerContainer->getPosition().x, 0.0f)); }