Garry's Mod Wiki

Panel:MoveTo

  Panel:MoveTo( number posX, number posY, number time, number delay = 0, number ease = -1, function callback = nil )

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 = nil
The function to be called once the animation finishes.
Function argument(s):
1 table animData - The AnimationData structure that was used.
2 Panel targetPanel - The panel object that was animated.

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