That requires quite a lot more work:
Lua Code:
ReturnCastbar = function()
-- Move the player castbar back to player.
local castbar = YourPlayerFrame.Castbar
castbar:ClearAllPoints()
castbar:SetAllPoints(YourPlayerFrame.Health)
end
OnEnter = function(self)
-- Move the player castbar to the raid frame we are hovering.
local castbar = YourPlayerFrame.Castbar
castbar.activeFrame = self
castbar:ClearAllPoints()
castbar:SetAllPoints(self.Health)
end
OnHide = function(self)
if(castbar.activeFrame == self) then
ReturnCastbar()
castbar.activeFrame = nil
end
end
-- on the raid frames:
-- Return the castbar if the unit disappears.
self:HookScript("OnHide", OnHide)
-- on the player frame:
-- Force it back when we stop casting.
castbar.PostCastFailed = ReturnCastbar
castbar.PostCastInterrupted = ReturnCastbar
castbar.PostCastStop = ReturnCastbar
castbar.PostChannelStop = ReturnCastbar
Might work.
Edit: No it won't, I'm completely missing the actual problem here being the initial anchoring, followed by re-anchoring when targeting a new unit. I'll throw some time at it tomorrow night or so.