element refactor - will return to this
This commit is contained in:
@@ -32,6 +32,7 @@ local Element = req("Element")
|
|||||||
-- externals
|
-- externals
|
||||||
---@type Animation
|
---@type Animation
|
||||||
local Animation = req("Animation")
|
local Animation = req("Animation")
|
||||||
|
local Transform = Animation.Transform
|
||||||
---@type Color
|
---@type Color
|
||||||
local Color = req("Color")
|
local Color = req("Color")
|
||||||
---@type Theme
|
---@type Theme
|
||||||
@@ -152,8 +153,12 @@ function flexlove.init(config)
|
|||||||
ScrollManager = ScrollManager,
|
ScrollManager = ScrollManager,
|
||||||
ErrorHandler = flexlove._ErrorHandler,
|
ErrorHandler = flexlove._ErrorHandler,
|
||||||
Performance = flexlove._Performance,
|
Performance = flexlove._Performance,
|
||||||
|
Transform = Transform,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Initialize Element module with dependencies
|
||||||
|
Element.init(flexlove._defaultDependencies)
|
||||||
|
|
||||||
if config.baseScale then
|
if config.baseScale then
|
||||||
flexlove.baseScale = {
|
flexlove.baseScale = {
|
||||||
width = config.baseScale.width or 1920,
|
width = config.baseScale.width or 1920,
|
||||||
@@ -934,7 +939,7 @@ function flexlove.new(props)
|
|||||||
|
|
||||||
-- If not in immediate mode, use standard Element.new
|
-- If not in immediate mode, use standard Element.new
|
||||||
if not flexlove._immediateMode then
|
if not flexlove._immediateMode then
|
||||||
return Element.new(props, flexlove._defaultDependencies)
|
return Element.new(props)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Auto-begin frame if not manually started (convenience feature)
|
-- Auto-begin frame if not manually started (convenience feature)
|
||||||
@@ -959,7 +964,7 @@ function flexlove.new(props)
|
|||||||
props._scrollX = state._scrollX or 0
|
props._scrollX = state._scrollX or 0
|
||||||
props._scrollY = state._scrollY or 0
|
props._scrollY = state._scrollY or 0
|
||||||
|
|
||||||
local element = Element.new(props, flexlove._defaultDependencies)
|
local element = Element.new(props)
|
||||||
|
|
||||||
-- Bind persistent state to element (ImmediateModeState)
|
-- Bind persistent state to element (ImmediateModeState)
|
||||||
-- Restore event handler state
|
-- Restore event handler state
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1238,12 +1238,15 @@ function TestElementUnhappyPaths:tearDown()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Test: Element with missing deps parameter
|
-- Test: Element with missing deps parameter
|
||||||
function TestElementUnhappyPaths:test_element_without_deps()
|
function TestElementUnhappyPaths:test_element_with_init()
|
||||||
|
-- Test that Element.new() works after FlexLove.init() is called
|
||||||
|
-- Element now uses module-level dependencies initialized via Element.init()
|
||||||
|
FlexLove.init() -- Ensure FlexLove is initialized
|
||||||
local Element = require("modules.Element")
|
local Element = require("modules.Element")
|
||||||
local success = pcall(function()
|
local success = pcall(function()
|
||||||
Element.new({}, nil)
|
Element.new({})
|
||||||
end)
|
end)
|
||||||
luaunit.assertFalse(success) -- Should error without deps
|
luaunit.assertTrue(success) -- Should work after Element.init() is called by FlexLove
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Test: Element with negative dimensions
|
-- Test: Element with negative dimensions
|
||||||
|
|||||||
Reference in New Issue
Block a user