- Added Timer

- Fixed BaseElement Visual request issues
- Added number animation
- Added entries animation
This commit is contained in:
Robert Jelic
2025-04-20 10:27:48 +02:00
parent 296e099e2c
commit d36c7e7867
9 changed files with 806 additions and 158 deletions

View File

@@ -329,6 +329,44 @@ Animation.registerAnimation("moveOffset", {
end
})
Animation.registerAnimation("number", {
start = function(anim)
anim.startValue = anim.element.get(anim.args[1])
anim.targetValue = anim.args[2]
end,
update = function(anim, progress)
local value = anim.startValue + (anim.targetValue - anim.startValue) * progress
anim.element.set(anim.args[1], math.floor(value))
return progress >= 1
end,
complete = function(anim)
anim.element.set(anim.args[1], anim.targetValue)
end
})
Animation.registerAnimation("entries", {
start = function(anim)
anim.startColor = anim.element.get(anim.args[1])
anim.colorList = anim.args[2]
end,
update = function(anim, progress)
local list = anim.colorList
local index = math.floor(#list * progress) + 1
if index > #list then
index = #list
end
anim.element.set(anim.args[1], list[index])
end,
complete = function(anim)
anim.element.set(anim.args[1], anim.colorList[#anim.colorList])
end
})
Animation.registerAnimation("morphText", {
start = function(anim)
local startText = anim.element.get(anim.args[1])

View File

@@ -147,7 +147,7 @@ local function setupObservers(element, expr, propertyName)
local observer = {
target = target,
property = prop,
callback = function()
callback = function()
element:updateRender()
end
}
@@ -198,7 +198,7 @@ end)
--- @usage local button = main:addButton({text="Exit"})
--- @usage button:setX("{parent.x - 12}")
--- @usage button:setBackground("{self.clicked and colors.red or colors.green}")
--- @usage button:setWidth("{self.text:len() + 2}")
--- @usage button:setWidth("{#self.text + 2}")
---@class Reactive
local BaseElement = {}

View File

@@ -177,8 +177,6 @@ function BaseElement:applyTheme(applyToChildren)
end
end
self.set(prop, value)
else
errorManager.error("Invalid property '" .. prop .. "' in theme for " .. self._values.type)
end
end
end