I threw this together real quick
Create a frame like you normally would, then put this in it's OnLoad script. Make sure you enable mouse clicks.
OnLoad:
Code:
local open = false; -- Don't change this
local xOffset = 50; -- How far to move left
local yOffset = 0; -- How far to move up
local animDuration = 2; -- How long should it take (in seconds)
local point, relTo, relPt, xOff, yOff; -- Don't change these
self.animGroup = self:CreateAnimationGroup("SlidingFrame");
self.anim = self.animGroup:CreateAnimation("Translation");
self.anim:SetDuration(animDuration);
self.animGroup:SetScript("OnFinished",function()
point, relTo, relPt, xOff, yOff = self:GetPoint();
if (open==false) then
self:ClearAllPoints();
self:SetPoint(point, relTo, relPt, xOff+xOffset, yOff);
else
self:ClearAllPoints();
self:SetPoint(point, relTo, relPt, xOff-xOffset, yOff);
end
end)
self:SetScript("OnMouseDown",function(self)
if open==false then
open = true;
self.anim:SetOffset(-xOffset,0);
self.animGroup:Play();
else
open = false;
self.anim:SetOffset(xOffset,0);
self.animGroup:Play();
end
end)
Currently it jitters at the end of the animation, but the frame ends up in the right spot.
I've gotta go to bed for now, I'll look further into this tomorrow!