# Animations

There is no official animations implementations in Enoria. However, every Enoria widget is a normal GUI Object (`Frame`, `TextLabel`, etc.). These can be animated with the `TweenPosition` or `TweenSize` functions. The simplest way to get a widget as a Roblox GUI object is to give it a name and to get it with the `GetElementByName` function of the `Context` object.

For instance, we have a menu with a play button that we want to hide (with slide animation):

```lua
local e = require(game.ReplicatedStorage.Enoria.Enoria)
local Widget = require(game.ReplicatedStorage.Enoria.Enoria.Parent.Widgets.Widget)

local Menu = {}
Menu.__index = Menu
setmetatable(Menu, Widget)

function Menu.new(context, title)
   local self = Widget.new(nil, nil, context)
   setmetatable(self, Menu)

   self.Visible = true
   self.Title = title

   return self
end

function Menu:Build()
    local tree
    if self.Visible then
        tree = self:BuildTree(
            e.Container({
                Name = "menuFrame",
                Child = e.Column({
                    HorizontalAlignment = Enum.HorizontalAlignment.Center,
                    Children = {
                        e.VerticalSpacer(16),
                        e.TextLabel(self.Title, { Class = "title" }),
                        e.Container({ Size = UDim2.new(0, 0, 0.5, 0), Class = "transp" }),
                        e.TextButton("Play", {
                            OnClick = function()
                                self.Context.GetElementByName("menuFrame"):TweenPosition(
                                    UDim2.new(1, 0, 0, 0),
                                    Enum.EasingDirection.In,
                                    Enum.EasingStyle.Sine,
                                    0.5,
                                    true,
                                    function()
                                        self:SetState(function()
                                            self.Visible = false
                                        end)
                                    end
                                )
                            end,
                            Class = "button"
                        })
                    }
                })
            })
        )
    else
        tree = self:BuildTree(
            e.TextButton("Open", {
                OnClick = function()
                    self:SetState(function()
                        self.Visible = true
                    end)
                end,
                Class = "button"
            })
        )
    end
   

   return tree
end

return Menu

```

At line 23 we give the menu Container a name. Then, at line 32, we can grab it by it's name and animated.

{% hint style="info" %}
The last parameter of TweenPosition is a callback function. In this example, we set the state to make the menu not visible anymore. If we decided to put it after the tweening, it would not work since it would set the state before the animation has finished to play.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://thebuildex.gitbook.io/enoria/animations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
