forked from wowgaming/3.3.5-interface-files
-
Notifications
You must be signed in to change notification settings - Fork 1
/
FadingFrame.lua
44 lines (43 loc) · 1.2 KB
/
FadingFrame.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function FadingFrame_SetFadeInTime(fadingFrame, time)
fadingFrame.fadeInTime = time;
end
function FadingFrame_SetHoldTime(fadingFrame, time)
fadingFrame.holdTime = time;
end
function FadingFrame_SetFadeOutTime(fadingFrame, time)
fadingFrame.fadeOutTime = time;
end
function FadingFrame_OnLoad(fadingFrame)
assert(fadingFrame);
fadingFrame.fadeInTime = 0;
fadingFrame.holdTime = 0;
fadingFrame.fadeOutTime = 0;
fadingFrame:Hide();
end
function FadingFrame_Show(fadingFrame)
assert(fadingFrame);
fadingFrame.startTime = GetTime();
fadingFrame:Show();
end
function FadingFrame_OnUpdate(fadingFrame)
assert(fadingFrame);
local elapsed = GetTime() - fadingFrame.startTime;
local fadeInTime = fadingFrame.fadeInTime;
if ( elapsed < fadeInTime ) then
local alpha = (elapsed / fadeInTime);
fadingFrame:SetAlpha(alpha);
return;
end
local holdTime = fadingFrame.holdTime;
if ( elapsed < (fadeInTime + holdTime) ) then
fadingFrame:SetAlpha(1.0);
return;
end
local fadeOutTime = fadingFrame.fadeOutTime;
if ( elapsed < (fadeInTime + holdTime + fadeOutTime) ) then
local alpha = 1.0 - ((elapsed - holdTime - fadeInTime) / fadeOutTime);
fadingFrame:SetAlpha(alpha);
return;
end
fadingFrame:Hide();
end