public
Description: WoW Addon - Crowd control assistance
Homepage: http://www.tekkub.net
Clone URL: git://github.com/tekkub/controlfreak.git
Click here to lend your support to: controlfreak and make a donation at www.pledgie.com !
tekkub (author)
Tue Feb 19 01:00:29 -0800 2008
commit  9f70bf216bf5a1e3e41bef4443f2ebb0a773ecce
tree    7686f62e64904247c963f1a9a3ec782c20b0e919
parent  8335514aac6167b53c963282c472a6b64f3cb618
controlfreak / tekKonfigFadeIn.lua
100644 25 lines (19 sloc) 0.749 kb
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
local lib, oldminor = LibStub:NewLibrary("tekKonfig-FadeIn", 1)
if not lib then return end
 
 
local starttimes, endtimes, OnUpdates = {}, {}, {}
local function OnUpdate(frame)
  local time = GetTime()
  if time >= (starttimes[frame] + endtimes[frame]) then
    frame:SetScript("OnUpdate", OnUpdates[frame])
    frame:SetAlpha(1)
  else frame:SetAlpha((time - starttimes[frame])/endtimes[frame]) end
end
 
-- Fades in a frame, if time is not passed 0.5sec is used
function lib.FadeIn(frame, time)
  time = time or 0.5
  assert(frame, "No frame passed")
  assert(time > 0, "Time must be positive")
 
  starttimes[frame], endtimes[frame], OnUpdates[frame] = GetTime(), time, frame:GetScript("OnUpdate")
  frame:SetAlpha(0)
  frame:SetScript("OnUpdate", OnUpdate)
end