How do I tween a ui list object while keeping its original position?

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

Not that I know of. You cant tween a position that is influenced by the ui element

1 Like

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!

1 Like

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…

That’s quite alright! So are you saying to add padding between a certain element and tweening it’s size aswell?

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

1 Like

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
image

1 Like

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?

Simple to fix

  1. Create a frame (holder) and put the pop parent on the frame
  2. 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)
1 Like

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.

  • Frame
    • Object

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.

1 Like

It works perfectly well! Thank you for your help!

What about meee what about meee

1 Like

You helped me the most, and you know that :smiley: