Panel/MoveTo

From Garry's Mod
Jump to: navigation, search
 Panel:MoveTo( )

Contents

Description

Moves the panel to the specified position using animation.

Arguments

number posX

The target x coordinate of the panel.

Arguments

number posY

The target y coordinate of the panel.

Arguments

number time

The time to perform the animation within.

Arguments

number delay=0

The delay before the animation starts.

Arguments

number ease=-1

The easing of the start and/or end speed of the animation. See Panel:NewAnimation for how this works.

Arguments

function callback

The function to be called once the animation finishes. Arguments are:

Examples

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


Personal tools
Navigation