As the title says, my issue lies with ScrollingFrames and how their rendering updates. It’s a little tricky to explain with words so I recorded a few videos (Video 1 is the bug, Video 2 is the desired).
Here’s the setup (full rbxl is attached as well at the bottom of the post):
- Have a ScrollingFrame (S) (I have it using
AutomaticCanvasSize = XYbut this is reproducable with any value) - Have a frame (F) positioned and sized absolutely inside of (S),
ClipsDescendants = false - Have a child frame (C) that exceeds the bounds of its parent (my example has
Size.X.Scale = 2.2) - Parent the (C) somewhere that’s visible so it renders
- After any delay >= 1 render frame, re-parent (C) to (F)
The issue when this happens is the part of the child frame that exceeds the bounds of its parent (the 1.2 part of the 2.2 size) acts as if it were a sticky HTML/CSS element, and does not go off-screen when it should. Video 1 is an example of this.
Expected behavior
I managed to get a working version (Video 2) by toggling visibility (by setting Size) to force a re-render, but I can visibly notice the invisible/visible switch due to the task.wait() (the frame wait is necessary for it to work) which I dislike and don’t want to happen in my game
Below is the entire script used to recreate this:
task.wait(0.5)
print('a')
-- clone and parent to something that's not the desired end-goal parent
local cl = script.Parent.Attachment.Frame:Clone()
cl.Parent = script.Parent
task.wait(1.5)
print('b')
-- re-parent after initially rendering
local newParent = script.Parent.ScrollingFrame['1']
cl.Parent = newParent
-- commenting everything below this line generates the results from Video1
-- currently generates the results from Video2
task.defer(function()
local oldSize = cl.Size
cl.Size = UDim2.fromScale(0,0)
task.wait()
cl.Size = oldSize
end)
Is there something wrong with what I’m doing? Can I force a re-render without the visual glitchiness?
The other things I’ve tried include changing just about every property you could think of in similar fashion to the script I attached. One thing I noticed during my test that may be a helpful piece of info is that the resizing only fixes it if it ever gets resized to be within the bounds of the parent, and then resized again to be outside of the parent.
For example, if I simply added and subtracted UDim2.fromOffset(1, 0) with the delay, it wouldn’t work – only when I change the size to be smaller than (or equal to) its parents size and back would it work.
Any help would be greatly appreciated, and as stated above, below is the full rbxl file for reference:
Sticky.rbxl (63.3 KB)
A private message is associated with this bug report