diff --git a/lib/utils/task.lua b/lib/utils/task.lua index 2593342..ec65b2b 100644 --- a/lib/utils/task.lua +++ b/lib/utils/task.lua @@ -33,11 +33,11 @@ function task.update(dt) t.elapsed = t.elapsed + dt * 1000 local progress = math.min(t.elapsed / t.duration, 1) local value = t.easing(progress) - + for key, targetValue in pairs(t.properties) do t.target[key] = lerp(t.initial[key], targetValue, value) end - + if progress >= 1 then t.completed = true table.remove(activeTweens, i) @@ -50,7 +50,8 @@ function task.update(dt) end --- Возвращает Completer — объект, который позволяет вручную завершить таску. ---- @return table completer { complete: fun(val: T) }, Task future +--- @generic T +--- @return { complete: fun(val: T) }, Task future function task.completer() local c = { completed = false, value = nil, cb = nil } function c:complete(val) @@ -61,8 +62,11 @@ function task.completer() end local future = function(callback) - if c.completed then callback(c.value) - else c.cb = callback end + if c.completed then + callback(c.value) + else + c.cb = callback + end end return c, future end @@ -86,7 +90,7 @@ end --- @return Task function task.tween(target, properties, duration, easing) task.cancel(target) -- Cancel previous animations on this target - + local initial = {} for k, _ in pairs(properties) do initial[k] = target[k]