mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 14:01:37 +00:00
Merge branch 'master' of https://github.com/boatbomber/rojo into headless-api
This commit is contained in:
commit
1ff018a2ce
35 changed files with 571 additions and 212 deletions
|
|
@ -40,11 +40,6 @@ end
|
|||
local DomLabel = Roact.Component:extend("DomLabel")
|
||||
|
||||
function DomLabel:init()
|
||||
self.maxElementHeight = 0
|
||||
if self.props.changeList then
|
||||
self.maxElementHeight = math.clamp(#self.props.changeList * 30, 30, 30 * 6)
|
||||
end
|
||||
|
||||
local initHeight = self.props.elementHeight:getValue()
|
||||
self.expanded = initHeight > 30
|
||||
|
||||
|
|
@ -118,7 +113,8 @@ function DomLabel:render()
|
|||
Size = UDim2.new(1, 0, 1, 0),
|
||||
[Roact.Event.Activated] = function()
|
||||
self.expanded = not self.expanded
|
||||
self.motor:setGoal(Flipper.Spring.new((self.expanded and self.maxElementHeight or 0) + 30, {
|
||||
local goalHeight = 30 + (if self.expanded then math.clamp(#self.props.changeList * 30, 30, 30 * 6) else 0)
|
||||
self.motor:setGoal(Flipper.Spring.new(goalHeight, {
|
||||
frequency = 5,
|
||||
dampingRatio = 1,
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -99,18 +99,30 @@ function VirtualScroller:refresh()
|
|||
})
|
||||
end
|
||||
|
||||
function VirtualScroller:didUpdate(previousProps)
|
||||
if self.props.count ~= previousProps.count then
|
||||
-- Items have changed, so we need to refresh
|
||||
self:refresh()
|
||||
end
|
||||
end
|
||||
|
||||
function VirtualScroller:render()
|
||||
local props, state = self.props, self.state
|
||||
|
||||
local items = {}
|
||||
for i = state.Start, state.End do
|
||||
local content = props.render(i)
|
||||
if content == nil then
|
||||
continue
|
||||
end
|
||||
|
||||
items["Item" .. i] = e("Frame", {
|
||||
LayoutOrder = i,
|
||||
Size = props.getHeightBinding(i):map(function(height)
|
||||
return UDim2.new(1, 0, 0, height)
|
||||
end),
|
||||
BackgroundTransparency = 1,
|
||||
}, props.render(i))
|
||||
}, content)
|
||||
end
|
||||
|
||||
return Theme.with(function(theme)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue