Skip to content

Commit

Permalink
Close changeList when the domlabel gets updated
Browse files Browse the repository at this point in the history
  • Loading branch information
boatbomber committed Jul 10, 2023
1 parent 5e7930c commit 7e298bd
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion plugin/src/App/Components/PatchVisualizer/DomLabel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ function DomLabel:init()
end)
end

function DomLabel:didUpdate(prevProps)
if
prevProps.instance ~= self.props.instance
or prevProps.patchType ~= self.props.patchType
or prevProps.name ~= self.props.name
or prevProps.changeList ~= self.props.changeList
then
-- Close the expansion when the domlabel is changed to a different thing
self.expanded = false
self.motor:setGoal(Flipper.Spring.new(30, {
frequency = 5,
dampingRatio = 1,
}))
end
end

function DomLabel:render()
local props = self.props

Expand Down Expand Up @@ -129,7 +145,7 @@ function DomLabel:render()
if props.changeList then
self.expanded = not self.expanded
local goalHeight = 30
+ (if self.expanded then math.clamp(#self.props.changeList * 30, 30, 30 * 6) else 0)
+ (if self.expanded then math.clamp(#props.changeList * 30, 30, 30 * 6) else 0)
self.motor:setGoal(Flipper.Spring.new(goalHeight, {
frequency = 5,
dampingRatio = 1,
Expand Down

0 comments on commit 7e298bd

Please sign in to comment.