Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit 1292aff

Browse files
committed
Fix autocomplete panel resizing
1 parent 6614762 commit 1292aff

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/UI/Panels/AutoCompleteModal.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,28 @@ private void UIPanel_OnPanelsReordered()
294294

295295
// UI Construction
296296

297+
const float MIN_X = 0.42f;
298+
const float MAX_Y = 0.6f;
299+
297300
protected internal override void DoSetDefaultPosAndAnchors()
298301
{
299302
Rect.pivot = new Vector2(0f, 1f);
300-
Rect.anchorMin = new Vector2(0.42f, 0.4f);
301-
Rect.anchorMax = new Vector2(0.68f, 0.6f);
303+
Rect.anchorMin = new Vector2(MIN_X, 0.4f);
304+
Rect.anchorMax = new Vector2(0.68f, MAX_Y);
305+
}
306+
307+
public override void OnFinishResize(RectTransform panel)
308+
{
309+
float xDiff = panel.anchorMin.x - MIN_X;
310+
float yDiff = panel.anchorMax.y - MAX_Y;
311+
312+
if (xDiff != 0 || yDiff != 0)
313+
{
314+
panel.anchorMin = new(MIN_X, panel.anchorMin.y - yDiff);
315+
panel.anchorMax = new(panel.anchorMax.x - xDiff, MAX_Y);
316+
}
317+
318+
base.OnFinishResize(panel);
302319
}
303320

304321
public override void ConstructPanelContent()

0 commit comments

Comments
 (0)