[Core] Fix a bug with the implementation of clip .childOffset

This commit is contained in:
Nic Barker 2025-05-01 17:21:09 +12:00
parent ea8288158e
commit 90b45f059c
2 changed files with 3 additions and 9 deletions

10
clay.h
View file

@ -2690,12 +2690,7 @@ void Clay__CalculateFinalLayout(void) {
if (mapping->layoutElement == currentElement) {
scrollContainerData = mapping;
mapping->boundingBox = currentElementBoundingBox;
if (clipConfig->horizontal) {
scrollOffset.x = mapping->scrollPosition.x;
}
if (clipConfig->vertical) {
scrollOffset.y = mapping->scrollPosition.y;
}
scrollOffset = clipConfig->childOffset;
if (context->externalScrollHandlingEnabled) {
scrollOffset = CLAY__INIT(Clay_Vector2) CLAY__DEFAULT_STRUCT;
}
@ -2917,8 +2912,7 @@ void Clay__CalculateFinalLayout(void) {
for (int32_t i = 0; i < context->scrollContainerDatas.length; i++) {
Clay__ScrollContainerDataInternal *mapping = Clay__ScrollContainerDataInternalArray_Get(&context->scrollContainerDatas, i);
if (mapping->layoutElement == currentElement) {
if (clipConfig->horizontal) { scrollOffset.x = mapping->scrollPosition.x; }
if (clipConfig->vertical) { scrollOffset.y = mapping->scrollPosition.y; }
scrollOffset = clipConfig->childOffset;
if (context->externalScrollHandlingEnabled) {
scrollOffset = CLAY__INIT(Clay_Vector2) CLAY__DEFAULT_STRUCT;
}

View file

@ -127,7 +127,7 @@ Clay_RenderCommandArray CreateLayout(void) {
.attachTo = CLAY_ATTACH_TO_ELEMENT_WITH_ID,
.offset = { .y = -(scrollData.scrollPosition->y / scrollData.contentDimensions.height) * scrollData.scrollContainerDimensions.height },
.zIndex = 1,
.parentId = 55,
.parentId = Clay_GetElementId(CLAY_STRING("MainContent")).id,
.attachPoints = { .element = CLAY_ATTACH_POINT_RIGHT_TOP, .parent = CLAY_ATTACH_POINT_RIGHT_TOP }
}
}) {