Panel Animation Helpers

Animation System Updated: Dec 10, 2025

Panel Animation Helpers

Convenience functions for common panel animations.

Position Animation

cLib.AnimatePos(panel, x, y, duration, ease, onComplete)
-- Slide panel to position
cLib.AnimatePos(panel, 100, 50, 0.3, cLib.Ease.OutQuad)

-- With callback
cLib.AnimatePos(panel, 0, 0, 0.5, cLib.Ease.OutCubic, function()
    print("Panel arrived!")
end)

Size Animation

cLib.AnimateSize(panel, width, height, duration, ease, onComplete)
-- Expand panel
cLib.AnimateSize(panel, 500, 400, 0.3)

-- Collapse
cLib.AnimateSize(panel, 0, 0, 0.2, cLib.Ease.InQuad)

Alpha Animation

cLib.AnimateAlpha(panel, alpha, duration, ease, onComplete)
-- Fade to 50% opacity
cLib.AnimateAlpha(panel, 127, 0.3)

-- Fade to full opacity
cLib.AnimateAlpha(panel, 255, 0.5)

Fade Effects

-- Fade in (sets visible and animates alpha 0→255)
cLib.FadeIn(panel, duration, ease, onComplete)

-- Fade out (animates alpha 255→0 then hides)
cLib.FadeOut(panel, duration, ease, onComplete)
-- Show panel with fade
cLib.FadeIn(panel, 0.3)

-- Hide panel with fade
cLib.FadeOut(panel, 0.2, nil, function()
    panel:Remove()
end)

Slide Effects

-- Slide in from direction
cLib.SlideIn(panel, direction, duration, ease, onComplete)

-- Slide out to direction
cLib.SlideOut(panel, direction, duration, ease, onComplete)

Directions: "left", "right", "top", "bottom"

-- Slide in from left
cLib.SlideIn(panel, "left", 0.3, cLib.Ease.OutCubic)

-- Slide out to right
cLib.SlideOut(panel, "right", 0.2)

-- Slide notification from top
cLib.SlideIn(notification, "top", 0.4, cLib.Ease.OutBack)

Pop Effects

Scale animation from/to center point.

-- Pop in (scale from 0 with overshoot)
cLib.PopIn(panel, duration, ease, onComplete)

-- Pop out (scale to 0)
cLib.PopOut(panel, duration, ease, onComplete)
-- Show modal with pop
cLib.PopIn(modal, 0.25, cLib.Ease.OutBack)

-- Close with pop
cLib.PopOut(modal, 0.15, cLib.Ease.InBack, function()
    modal:Remove()
end)

Complete Example

function ShowNotification(message)
    local notif = vgui.Create("DPanel")
    notif:SetSize(cLib.Scale(300), cLib.Scale(60))
    notif:SetPos(ScrW() - cLib.Scale(320), -cLib.Scale(60))
    
    -- Setup appearance...
    
    -- Slide in from top-right
    cLib.SlideIn(notif, "top", 0.4, cLib.Ease.OutBack)
    
    -- Auto-hide after 3 seconds
    timer.Simple(3, function()
        if IsValid(notif) then
            cLib.SlideOut(notif, "right", 0.3, nil, function()
                notif:Remove()
            end)
        end
    end)
end