Skip to content

Commit b136e3b

Browse files
committed
fix scrolllayer improper culling
1 parent ecdd3b2 commit b136e3b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

loader/src/ui/nodes/ScrollLayer.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,18 @@ void GenericContentLayer::setPosition(CCPoint const& pos) {
1818
// all be TableViewCells
1919
CCLayerColor::setPosition(pos);
2020

21+
CCSize scrollLayerSize{};
22+
if (auto parent = this->getParent()) {
23+
scrollLayerSize = parent->getContentSize();
24+
}
25+
2126
for (auto child : CCArrayExt<CCNode*>(m_pChildren)) {
22-
auto y = this->getPositionY() + child->getPositionY();
23-
child->setVisible(!((m_obContentSize.height < y) || (y < -child->getContentSize().height)));
27+
float childY = this->getPositionY() + child->getPositionY();
28+
float childTop = childY + (1.f - child->getAnchorPoint().y) * child->getScaledContentSize().height;
29+
float childBottom = childY - child->getAnchorPoint().y * child->getScaledContentSize().height;
30+
bool visible = childTop > 0 && childBottom < scrollLayerSize.height;
31+
32+
child->setVisible(visible);
2433
}
2534
}
2635

0 commit comments

Comments
 (0)