mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-08 06:30:00 +00:00
ui-widgets: only run animation on value change
This commit is contained in:
+11
-4
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user