ui-widgets: only run animation on value change

This commit is contained in:
shagu
2020-11-27 16:51:53 +01:00
parent 2071ff0b2a
commit 605c928154
+11 -4
View File
@@ -21,26 +21,29 @@ do -- statusbars
local handlers = {
["DisplayValue"] = function(self, val)
val = val > self.max and self.max or val < self.min and self.min or val
val = val > self.max and self.max or val
val = val < self.min and self.min or val
-- remove animation queue
if val == self.val_ then
animations[self] = nil
end
-- set current visible value
self.val_ = val
if self.mode == "vertical" then
height = self:GetHeight()
if pfUI.expansion == "vanilla" then height = height / self:GetEffectiveScale() end
point = height / (self.max - self.min) * (val - self.min)
self.bar:SetPoint("TOPLEFT", self, "TOPLEFT", 0, - height + point)
self.bg:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 0, point)
self.val_ = val
else
width = self:GetWidth()
if pfUI.expansion == "vanilla" then width = width / self:GetEffectiveScale() end
point = width / (self.max - self.min) * (val - self.min)
self.bar:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", - width + point, 0)
self.bg:SetPoint("TOPLEFT", self, "TOPLEFT", point, 0)
self.val_ = val
end
end,
@@ -56,7 +59,11 @@ do -- statusbars
["SetValue"] = function(self, val)
self.val = val or 0
animations[self] = true
-- start animation on difference
if self.val_ ~= self.val then
animations[self] = true
end
end,
["SetStatusBarTexture"] = function(self, r, g, b, a)