Update with some fixxes and improvements

This commit is contained in:
Robert Jelic
2025-02-20 11:32:33 +01:00
parent 2dfb2443cd
commit 6393198552
14 changed files with 446 additions and 154 deletions

View File

@@ -48,7 +48,7 @@ function AnimationInstance.new(element, animType, args, duration, easing)
self.element = element
self.type = animType
self.args = args
self.duration = duration
self.duration = duration or 1
self.startTime = 0
self.isPaused = false
self.handlers = registeredAnimations[animType]
@@ -288,6 +288,26 @@ Animation.registerAnimation("move", {
end
})
Animation.registerAnimation("moveOffset", {
start = function(anim)
anim.startX = anim.element.get("offsetX")
anim.startY = anim.element.get("offsetY")
end,
update = function(anim, progress)
local x = anim.startX + (anim.args[1] - anim.startX) * progress
local y = anim.startY + (anim.args[2] - anim.startY) * progress
anim.element.set("offsetX", math.floor(x))
anim.element.set("offsetY", math.floor(y))
return progress >= 1
end,
complete = function(anim)
anim.element.set("offsetX", anim.args[1])
anim.element.set("offsetY", anim.args[2])
end
})
Animation.registerAnimation("morphText", {
start = function(anim)
local startText = anim.element.get(anim.args[1])
@@ -384,12 +404,12 @@ function VisualElement.hooks.dispatchEvent(self, event, ...)
if animation then
animation:event(event, ...)
end
return true
end
end
---@private
function VisualElement.setup(element)
VisualElementBaseDispatchEvent = element.dispatchEvent
element.defineProperty(element, "animation", {default = nil, type = "table"})
element.listenTo(element, "timer")
end

View File

@@ -313,6 +313,11 @@ function API.start(name, options)
profile.name = name
profile.startTime = os.clock() * 1000
profile.custom = true
profile.calls = 0
profile.totalTime = 0
profile.minTime = math.huge
profile.maxTime = 0
profile.lastTime = 0
activeProfiles[name] = profile
end

View File

@@ -64,7 +64,7 @@ local function parseExpression(expr, element, propName)
elseif objName == "parent" then
return element.parent.get(propName)
else
local target = element:getBaseFrame():getChild(objName)
local target = element.parent:getChild(objName)
if not target then
errorManager.header = "Reactive evaluation error"
errorManager.error("Could not find element: " .. objName)
@@ -103,7 +103,7 @@ local function validateReferences(expr, element)
return false
end
else
local target = element:getBaseFrame():getChild(ref)
local target = element.parent:getChild(ref)
if not target then
errorManager.header = "Reactive evaluation error"
errorManager.error("Referenced element not found: " .. ref)