Panel:MoveTo
Panel:MoveTo( number posX, number posY, number time, number delay = 0, number ease = -1, function callback )
Description
Moves the panel to the specified position using animation.
Setting the ease argument to 0 will result in the animation happening instantly, this applies to all MoveTo/SizeTo functions
Arguments
5 number ease = -1
The easing of the start and/or end speed of the animation. See Panel:NewAnimation for how this works.
6 function callback
The function to be called once the animation finishes. Arguments are:
- table animData - The Structures/AnimationData that was used.
- Panel pnl - The panel object that was moved.
Example
Move panel to center
local frame = vgui.Create("DFrame")
frame:SetSize(ScrW() / 4, ScrH() / 4)
frame:SetPos(ScrW() / 4, ScrH() / 2)
frame:SetTitle("MoveTo Example")
local btn = vgui.Create("DButton", frame)
btn:SetSize(frame:GetWide() / 2, frame:GetTall() / 3)
btn:Center()
btn:SetText("Move !")
btn.DoClick = function(self)
frame:MoveTo(ScrW() / 2 - frame:GetWide() / 2, ScrH() / 2 - frame:GetTall() / 2, 1, 0, -1, function()
self:SetText("Yeah !")
end)
end