Is it possible to tween an object in a UiListLayout, while making sure it keeps its original center? When the size of an object is changed its center is changed as well because of its UiList constraint. I would prefer that it would keep its position while changing size for a cleaner look. Any Ideas?
Here is the tween function:
local function tweenPop(obj, target, formersize)
local setsize
if formersize then
setsize = formersize
else
setsize = UDim2.new(0,0,0,0)
end
if target then
local tween = tweenservice:Create(obj, TweenInfo.new(1,Enum.EasingStyle.Bounce), {Size = target})
obj.Size = setsize
tween:Play()
else
local targetsize = obj.Size
local tween = tweenservice:Create(obj, TweenInfo.new(1,Enum.EasingStyle.Bounce), {Size = targetsize})
obj.Size = setsize
tween:Play()
end
end
im assuming youre talking about the object tweening from the left and not the center? to make it tween outwards from the center, make the tweened object have an anchor point of 0.5, 0.5. If this isnt your issue please explain more in depth to me and iād be glad to help you!
This is my exact issue! However my image label has an anchor point of 0.5, 0.5. I want to know if thereās a way to bypass the uilistlayout forcing the size to change from the left.
you could apply manual padding based on the nth element of an array and adding it on the x in your case, so element 5 would clone out on 0.5 on the x scale (assuming each one has a 0.1 x difference) to combat this issue, so get the number of children inside your element container, and apply the padding based on the nth element
To address the issue of a child being removed, like the 4th children when theres 5, just look for childremoved calls and apply the neccessary change, shifting the nth elements above the change, so if 4th was removed (try naming them numerical numbers based on the n element to help), apply the padding changes to 5ā¦n. Sorry if i made this complicated, im sure the answer is much simplier for ohter people but this way also worksā¦
yes, basically a manual Uilistlayout, so you dont use your current one and do what i said basically,
heres a code example
local GUI = (PATH_TO_GUI) :: ScreenGui
function UpdateGuiArr()
local Children = GUI:GetChildren()
local Temps = {}
for _, child in pairs(Children) do
if not child:IsA("ImageLabel") then continue end --// i assumed your children were images based on your previous message
table.insert(Temps, child)
end
table.sort(Temps, function(a,b) return tonumber(a.Name) or 0 < tonumber(b.Name) or 0 end) --// If you named the children like i siad in my statment
for n, child in ipairs(Temps) do
child.Name = tostring(n)
child.Position = UDim2.new(0.1 * (n - 1), 0, 0, 0) --// assuming your padding is 0.1 per element
end
end
GUI.ChildAdded:Connect(function()
task.wait(0.05) --// remove if you need im not sure how you handled cloning of the template
UpdateGuiArr()
end)
GUI.ChildRemoved:Connect(function()
task.wait(0.05) --// remove if you need im not sure how you handled cloning of the template
UpdateGuiArr()
end)
again this is probably overcomplicated, the anchor point solution should have fixed your issue
You should make the gui element thatās influenced by the uilistlayout invisible and use itās child as the āmainā frame to tween.
This is how i created this donation board
I canāt tween the numbers 1, 10, 11, 12, 13 because of the same issue youāre having so instead i make them invisible and tween itās child called Template
Iāll attempt this in the morning and update you on how my progress has gone. This might only be temporary since there can be 12 uilistlayouts in the game at once and it may have performance issues.
Making a frame for every single user in the voice room I have may not be optimal. In the morning I will try to create a frame for the player that is being added then remove it from it after? Weāll see how it goes
Iāve just tried this. I am tweening the correct thing but it still grows from the left instead of the middle. When changing itās size (while being inside the designated frame) it changes itās size from the center but not when tweening. Any solution?
Create a frame (holder) and put the pop parent on the frame
make holder size like the end size of the pop animation
So how it work it creates a holder instead of the pop but the pop is inside the holder so change the tween animation from 0 to 1 i see that ur using offset to animate if the offset size when the animation is ending for example 0,50,0,50 :
local holder = Instance.new(āFrameā)
holder.Transparency = 1
holder.Size = Udim2.new(0,50,0,50)
holder.Parent = ā the pop parent u parent the pop
ā Then the pop parent
Pop.Parent = holder
ā continue ur tween but change the end tween size to Udim2(1,0,1,0) or Udim2(0.9,0,0.9,0)
Looking back at my script after a great delay. I realize that I currently have a failed holder frame. Would I need to tween the parent or object in your opinion. Once again Iām sorry for the long delay.
The Frame is what determines the position in the list. Itās invisible, it just defines a layout index/position and maximum size.
The Object is what you tween. Itās got an AnchorPoint of 0.5, 0.5 so that when it resizes, it does so with respect to the middle of the Frame parent.