Skip to content

Commit

Permalink
fix icon animations snapping due to perform layout
Browse files Browse the repository at this point in the history
  • Loading branch information
plally committed Feb 3, 2024
1 parent 3a8df93 commit 3ad44d2
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lua/mapvote/client/vgui/mapvote_panel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ function PANEL:PerformLayout()
-- This is expensive, but must be done so avatar positions dont get misaligned when parent panel is being minimized and resized
for _, map in ipairs( self.maps ) do
for i, voter in ipairs( map.voters ) do
local newX, newY, willOverflow = self:CalculateDesiredAvatarIconPosition( map, i )
voter:SetPos( newX, newY )
voter:SetVisible( not willOverflow )
if not voter.inAnimation then
local newX, newY, willOverflow = self:CalculateDesiredAvatarIconPosition( map, i )
voter:SetPos( newX, newY )
voter:SetVisible( not willOverflow )
end
end
end
end
Expand Down Expand Up @@ -83,8 +85,10 @@ function PANEL:SetVote( identifier, mapIndex )
local voter = oldMapData.voters[i]
local newX, newY, willOverflow = self:CalculateDesiredAvatarIconPosition( oldMapData, i )
voter:SetVisible( true )
voter:MoveTo( newX, newY, 0.2, nil, nil, function( _, pnl )
voter.inAnimation = true
voter:MoveTo( newX, newY, 0.3, nil, 1, function( _, pnl )
pnl:SetVisible( not willOverflow )
pnl.inAnimation = false
end )
end

Expand All @@ -103,10 +107,10 @@ function PANEL:SetVote( identifier, mapIndex )

local newX, newY, willOverflow = self:CalculateDesiredAvatarIconPosition( mapData )
panel:SetVisible( true )
panel:MoveTo( newX, newY, 0.2, nil, nil, function()
if willOverflow then
panel:SetVisible( not willOverflow )
end
panel.inAnimation = true
panel:MoveTo( newX, newY, 0.3, nil, 1, function( _, pnl )
pnl:SetVisible( not willOverflow )
pnl.inAnimation = false
end )
end

Expand Down

0 comments on commit 3ad44d2

Please sign in to comment.