Garry's Mod Wiki

Revision Difference

Panel:MoveTo#517732

<function name="MoveTo" parent="Panel" type="classfunc"> <description>Moves the panel to the specified position using animation.</description> <realm>Client</realm> <args> <arg name="posX" type="number">The target x coordinate of the panel.</arg> <arg name="posY" type="number">The target y coordinate of the panel.</arg> <arg name="time" type="number">The time to perform the animation within.</arg> <arg name="delay" type="number" default="0">The delay before the animation starts.</arg> <arg name="ease" type="number" default="-1">The easing of the start and/or end speed of the animation. See &lt;page&gt;Panel:NewAnimation&lt;/page&gt; for how this works.</arg> <arg name="callback" type="function">The function to be called once the animation finishes. Arguments are:&#xA;* &lt;page&gt;table&lt;/page&gt; animData - The &lt;page&gt;AnimationData that was used.&lt;/page&gt;&#xA;* &lt;page&gt;Panel&lt;/page&gt; pnl - The panel object that was moved.</arg>⤶ <arg name="ease" type="number" default="-1">The easing of the start and/or end speed of the animation. See <page>Panel:NewAnimation</page> for how this works.</arg> <arg name="callback" type="function">The function to be called once the animation finishes. Arguments are:⤶ * <page>table</page> animData - The <page>AnimationData that was used.</page>⤶ * <page>Panel</page> pnl - The panel object that was moved.</arg>⤶ </args> </function> <example> <description>Move panel to center</description> <code> 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 </code> </example>