MCPcopy Create free account
hub / github.com/Snapchat/Valdi / canScroll

Method canScroll

valdi/src/valdi/runtime/Context/ViewNode.cpp:1162–1190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1160 case SimplifiedScrollDirectionLeftToRight:
1161 return contentSize.width - frame.width - directionDependentContentOffset.x;
1162 case SimplifiedScrollDirectionRightToLeft:
1163 return directionDependentContentOffset.x;
1164 }
1165 }
1166 return 0;
1167}
1168
1169bool ViewNode::canScroll(const Point& parentDirectionDependentVisual, ScrollDirection scrollDirection) {
1170 auto frame = getCalculatedFrame();
1171 if (!frame.contains(parentDirectionDependentVisual)) {
1172 return false;
1173 }
1174
1175 auto simplifiedScrollDirection = simplifyScrollDirection(scrollDirection);
1176
1177 // manually declared always scrollable elements
1178 if (_flags[kCanAlwaysScrollHorizontal] && (simplifiedScrollDirection == SimplifiedScrollDirectionLeftToRight ||
1179 simplifiedScrollDirection == SimplifiedScrollDirectionRightToLeft)) {
1180 return true;
1181 }
1182 if (_flags[kCanAlwaysScrollVertical] && (simplifiedScrollDirection == SimplifiedScrollDirectionTopToBottom ||
1183 simplifiedScrollDirection == SimplifiedScrollDirectionBottomToTop)) {
1184 return true;
1185 }
1186
1187 if (getCanScrollDistance(scrollDirection) > 0) {
1188 return true;
1189 }
1190 Point selfDirectionDependentVisual = convertParentVisualToSelfVisual(parentDirectionDependentVisual);
1191 for (ViewNode* childViewNode : *this) {
1192 if (childViewNode->canScroll(selfDirectionDependentVisual, scrollDirection)) {
1193 return true;

Callers 2

TESTFunction · 0.80
canViewNodeScrollMethod · 0.80

Calls 1

containsMethod · 0.65

Tested by 1

TESTFunction · 0.64