From cf48fc372e6fec17922cf6705fbe2f3a0ad5961b Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 1 Nov 2021 22:58:37 +0100 Subject: [PATCH] skip unnecessary relevant children updates for panels --- MLEM.Ui/Elements/Panel.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/MLEM.Ui/Elements/Panel.cs b/MLEM.Ui/Elements/Panel.cs index 9c8d8dd..aeb703c 100644 --- a/MLEM.Ui/Elements/Panel.cs +++ b/MLEM.Ui/Elements/Panel.cs @@ -115,10 +115,13 @@ namespace MLEM.Ui.Elements { private void ScrollChildren() { if (!this.scrollOverflow) return; - var offset = -this.ScrollBar.CurrentValue; - foreach (var child in this.GetChildren(c => c != this.ScrollBar, true)) - child.ScrollOffset = new Vector2(0, offset); - this.relevantChildrenDirty = true; + var offset = new Vector2(0, -this.ScrollBar.CurrentValue); + foreach (var child in this.GetChildren(c => c != this.ScrollBar, true)) { + if (child.ScrollOffset != offset) { + child.ScrollOffset = offset; + this.relevantChildrenDirty = true; + } + } } ///