-
Notifications
You must be signed in to change notification settings - Fork 330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Absolutely positioned elements do not trigger clipping on parent elements #235
Comments
Hi and thanks for the suggestion. This might be a bit tricky in RmlUi, since absolute offseting is done separately and after layouting. Thus, say we have scrollbars appearing due to the absolute positioned box. Then we would need to re-layout, but we only know this after we have performed the layout step. At least this is my understanding right now, I will investigate a bit more to see if it is possible somehow without rewriting the whole layout engine, or in case my understanding is wrong. Just to be clear, in CSS you would also have to add |
Hi, I have The layout step proceeds up the DOM tree right? If I understand the code correctly the absolute elements are being linked/assigned to the ancestor that they are being positioned relative to; perhaps you can layout absolute elements as soon as that element is positioned and check for overflow then? Like in
I think this is how overflow is handled for block level elements? Do absolutely positioned elements need to be different? |
The library is generally written with the assumption that offseting can be done completely separate from layouting. I'm not sure why this was done back in the day, but one very nice benefit is that we can scroll and move things around without invoking any layouting steps at all. You can also see based on However, I do have another suggestion, and I wonder if this could be a suitable way to solve the issue. What if we add an This would still be a workaround in some sense, but at least it is a lot prettier than a large invisible element, what do you think? |
I think having |
I went ahead and implemented I had to simultaneously change the Updated the documentation as well, our |
Works as intended, thank you! |
Reopening this to point something out: clip always always clips. Even if there is a child element with I tested the above and that works, let me know if you want me to draft up a quick rml snippet for this case. Edit: Too quick! That is not a fix because it messes with overflow clipping! |
V2: |
Yeah, I wasn't sure when implementing this how or if it should interact with other values. I'm completely open to suggestions and even better pull requests ;) Your latter solution sounds good to me. |
Pull request #251 👌 |
I noticed that absolutely positioned elements that exit the bounds of their parent element do not trigger clipping when overflow is enabled. In some cases I have used a workaround of having another empty element in that same parent to trigger the overflow, but it's not a nice solution.
Commenting out the
if (clipping_element->GetClientWidth() < clipping_element->GetScrollWidth() - 0.5f || clipping_element->GetClientHeight() < clipping_element->GetScrollHeight() - 0.5f)
In ElementUtilities.cpp allows absolutely positioned elements to be clipped too, but it's not an efficient solution. Only including a clipping region when relevant sounds like a good idea, so the real solution is probably to have absolutely positioned elements properly trigger an overflow when they are out of bounds (which is also the normal HTML/CSS behaviour I believe).
Excluding a repro example, should be easy enough to do with an absolutely positioned div overflowing an
overflow: hidden
parent.The text was updated successfully, but these errors were encountered: