Back to Home

ESO Lua File v101032

libraries/zo_labelrevealanimation/zo_labelrevealanimation.lua

[◄ back to folders ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
ZO_LabelRevealAnimation_Mixin = {}
function ZO_LabelRevealAnimation_Mixin:Initialize()
    self.mask = self:GetNamedChild("Mask")
    self.text = self.mask:GetNamedChild("Text")
    self.text:SetHandler("OnRectWidthChanged", function(_, newWidth)
        self:SetWidth(newWidth)
        self.mask:SetWidth(newWidth)
        if self.sizeAnimation then
            self.sizeAnimation:SetEndWidth(newWidth)
        end
    end)
    self.text:SetHandler("OnRectHeightChanged", function(_, newHeight)
        self:SetHeight(newHeight)
        self.mask:SetHeight(newHeight)
        if self.sizeAnimation then
            self.sizeAnimation:SetEndHeight(newHeight)
        end
    end)
end
function ZO_LabelRevealAnimation_Mixin:SetMaskAnchor(primaryAnchor, secondaryAnchor)
    self.mask:ClearAnchors()
    self.mask:SetAnchor(primaryAnchor)
    if secondaryAnchor then
        self.mask:SetAnchor(secondaryAnchor)
    end
end
function ZO_LabelRevealAnimation_Mixin:SetSizeAnimation(sizeAnimation)
    self.sizeAnimation = sizeAnimation
end
function ZO_LabelRevealAnimation_Mixin:SetText(text)
    self.text:SetText(text)
    self.text:GetWidth() -- Force a clean to update the rect
end
    zo_mixin(control, ZO_LabelRevealAnimation_Mixin)
    control:Initialize()
end