Try this out
Lua Code:
local queued, casting
local OnEnter = function(self)
if(not casting) then
local castbar = YourPlayerFrame.Castbar
castbar:ClearAllPoints()
castbar:SetAllPoints(self.Health)
else
queued = self
end
end
local OnHide = function()
local castbar = YourPlayerFrame.Castbar
castbar:ClearAllPoints()
castbar:SetAllPoints(YourPlayerFrame.Health)
end
local CastStarted = function()
casting = true
end
local CastEnded = function()
if(queued) then
OnEnter(queued)
queued = nil
casting = nil
else
OnHide()
end
end
-- on the raid frames:
-- Return the castbar if the unit disappears.
self:HookScript('OnHide', OnHide)
self:HookScript('OnEnter', OnEnter)
-- on the player frame:
castbar.PostCastFailed = CastEnded
castbar.PostCastInterrupted = CastEnded
castbar.PostCastStop = CastEnded
castbar.PostChannelStop = CastEnded
castbar.PostCastStart = CastStarted
castbar.PostChannelStart = CastStarted