Skip to content

Commit 4dc91e3

Browse files
take margin into account when clamping scroll to contents size
1 parent 4cff094 commit 4dc91e3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ui/ui.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2731,8 +2731,8 @@ void oc_ui_layout_compute_rect(oc_ui_context* ui, oc_ui_box* box, oc_vec2 pos)
27312731
}
27322732

27332733
//NOTE: clamp scroll to max contents and offset current position by it
2734-
box->scroll.x = oc_clamp(box->scroll.x, 0, box->childrenSum[0] - box->rect.w);
2735-
box->scroll.y = oc_clamp(box->scroll.y, 0, box->childrenSum[1] - box->rect.h);
2734+
box->scroll.x = oc_clamp(box->scroll.x, 0, box->childrenSum[0] + 2 * margin.x - box->rect.w);
2735+
box->scroll.y = oc_clamp(box->scroll.y, 0, box->childrenSum[1] + 2 * margin.y - box->rect.h);
27362736
currentPos.x -= box->scroll.x;
27372737
currentPos.y -= box->scroll.y;
27382738

0 commit comments

Comments
 (0)