Garry's Mod Wiki

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

1 number posX
The target x coordinate of the panel.
2 number posY
The target y coordinate of the panel.
3 number time
The time to perform the animation within.
4 number delay = 0
The delay before the animation starts.
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:

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