I want to make a button dynamically respond to the chat, so that they are never overlapping. The only way I know how to do this is by reading the ChatInputBarConfiguration’s AbsolutePosition and AbsoluteSize properties to obtain knowledge of where the chat rectangle is.
However, the AbsoluteSize property changes unnecessarily when the chat is hidden, which means any layouting which relies on that value will have a noticeable jitter - in part because the property changes a frame before the actual change occurs visually.
Here’s some videos demonstrating this:
I expect that the property should not change unnecessarily when the chat is hidden, and also that the timing of property changes should be properly synchronized with the visual rendering of the chat so that there isn’t a frame of lag on the chat’s part.
This problem can also be worked around using the following code.
local WasChatActive = nil :: boolean?
local DelayFrameIndex = 0
local ChatWindowBottom = 0
local function RenderStepped()
local IsChatActive = StarterGui:GetCore("ChatActive")
if WasChatActive ~= IsChatActive then
WasChatActive = IsChatActive
DelayFrameIndex = 1
end
if DelayFrameIndex <=
-- Delay 3 frames when opening, 2 when closing.
(if IsChatActive then 3 else 2)
then
DelayFrameIndex += 1
elseif not IsChatActive then
ChatWindowBottom = 0
else
ChatWindowBottom =
ChatInputBarConfiguration.AbsolutePosition.Y +
ChatInputBarConfiguration.AbsoluteSize.Y +
4
end
end