mirror of
https://github.com/geode-sdk/geode.git
synced 2025-03-29 14:19:51 -04:00
fix scrolllayer improper culling
This commit is contained in:
parent
ecdd3b290f
commit
b136e3b0e6
1 changed files with 11 additions and 2 deletions
|
@ -18,9 +18,18 @@ void GenericContentLayer::setPosition(CCPoint const& pos) {
|
|||
// all be TableViewCells
|
||||
CCLayerColor::setPosition(pos);
|
||||
|
||||
CCSize scrollLayerSize{};
|
||||
if (auto parent = this->getParent()) {
|
||||
scrollLayerSize = parent->getContentSize();
|
||||
}
|
||||
|
||||
for (auto child : CCArrayExt<CCNode*>(m_pChildren)) {
|
||||
auto y = this->getPositionY() + child->getPositionY();
|
||||
child->setVisible(!((m_obContentSize.height < y) || (y < -child->getContentSize().height)));
|
||||
float childY = this->getPositionY() + child->getPositionY();
|
||||
float childTop = childY + (1.f - child->getAnchorPoint().y) * child->getScaledContentSize().height;
|
||||
float childBottom = childY - child->getAnchorPoint().y * child->getScaledContentSize().height;
|
||||
bool visible = childTop > 0 && childBottom < scrollLayerSize.height;
|
||||
|
||||
child->setVisible(visible);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue