Unverified Commit 5a6cf970 authored by Adrian L Lange's avatar Adrian L Lange Committed by GitHub

castbar: Account for orientation and reverse fill for Spark repositioning (#408)

Fixes #407
parent 4e6684af
......@@ -463,7 +463,15 @@ local function onUpdate(self, elapsed)
self:SetValue(duration)
if(self.Spark) then
self.Spark:SetPoint('CENTER', self, 'LEFT', (duration / self.max) * self:GetWidth(), 0)
local horiz = self.horizontal
local size = self[horiz and 'GetWidth' or 'GetHeight'](self)
local offset = (duration / self.max) * size
if(self:GetReverseFill()) then
offset = size - offset
end
self.Spark:SetPoint('CENTER', self, horiz and 'LEFT' or 'BOTTOM', horiz and offset or 0, horiz and 0 or offset)
end
elseif(self.channeling) then
local duration = self.duration - elapsed
......@@ -495,7 +503,15 @@ local function onUpdate(self, elapsed)
self.duration = duration
self:SetValue(duration)
if(self.Spark) then
self.Spark:SetPoint('CENTER', self, 'LEFT', (duration / self.max) * self:GetWidth(), 0)
local horiz = self.horizontal
local size = self[horiz and 'GetWidth' or 'GetHeight'](self)
local offset = (duration / self.max) * size
if(self:GetReverseFill()) then
offset = size - offset
end
self.Spark:SetPoint('CENTER', self, horiz and 'LEFT' or 'BOTTOM', horiz and offset or 0, horiz and 0 or offset)
end
elseif(self.holdTime > 0) then
self.holdTime = self.holdTime - elapsed
......@@ -536,6 +552,7 @@ local function Enable(self, unit)
self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_STOP', UNIT_SPELLCAST_CHANNEL_STOP)
end
element.horizontal = element:GetOrientation() == 'HORIZONTAL'
element.holdTime = 0
element:SetScript('OnUpdate', element.OnUpdate or onUpdate)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment