1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 08:12:56 +08:00

Handle null and invalidation of headers.

This commit is contained in:
Huo Yaoyuan 2017-05-21 02:37:34 +08:00
parent e040f297c6
commit 72621c81dc

View File

@ -33,6 +33,7 @@ namespace osu.Game.Graphics.Containers
expandableHeader.Depth = float.MinValue; expandableHeader.Depth = float.MinValue;
Add(expandableHeader); Add(expandableHeader);
lastKnownScroll = float.NaN;
} }
} }
@ -50,6 +51,7 @@ namespace osu.Game.Graphics.Containers
fixedHeader.Depth = float.MinValue / 2; fixedHeader.Depth = float.MinValue / 2;
Add(fixedHeader); Add(fixedHeader);
lastKnownScroll = float.NaN;
} }
} }
@ -79,6 +81,7 @@ namespace osu.Game.Graphics.Containers
originalSectionMargin = sections[0].Margin; originalSectionMargin = sections[0].Margin;
sectionsContainer.Add(sections); sectionsContainer.Add(sections);
SelectedSection.Value = sections[0]; SelectedSection.Value = sections[0];
lastKnownScroll = float.NaN;
} }
} }
@ -104,7 +107,7 @@ namespace osu.Game.Graphics.Containers
}); });
} }
float lastKnownScroll = float.NaN; float lastKnownScroll;
protected override void UpdateAfterChildren() protected override void UpdateAfterChildren()
{ {
base.UpdateAfterChildren(); base.UpdateAfterChildren();
@ -116,14 +119,12 @@ namespace osu.Game.Graphics.Containers
updateSectionMargin(); updateSectionMargin();
} }
if (expandableHeader == null) return;
float currentScroll = ScrollContainer.Current; float currentScroll = ScrollContainer.Current;
if (currentScroll != lastKnownScroll) if (currentScroll != lastKnownScroll)
{ {
lastKnownScroll = currentScroll; lastKnownScroll = currentScroll;
if (expandableHeader != null) if (expandableHeader != null && fixedHeader != null)
{ {
float offset = Math.Min(expandableHeader.Height, currentScroll); float offset = Math.Min(expandableHeader.Height, currentScroll);