Skip to content

Commit f1deec0

Browse files
committed
Fix some elements is invisible when dragging virtualized list
1 parent 51664da commit f1deec0

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

Editor/Elements/TriListElement.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,10 @@ private void DrawElementBackgroundCallback(Rect rect, int index, bool isActive,
418418
if (_lastInvisibleElement.HasValue && index + 1 < _lastInvisibleElement.Value ||
419419
_lastVisibleElement.HasValue && index - 1 > _lastVisibleElement.Value)
420420
{
421-
return;
421+
if (index != _reorderableListGui.index)
422+
{
423+
return;
424+
}
422425
}
423426

424427
if (_showAlternatingBackground && index % 2 != 0)
@@ -440,7 +443,10 @@ private void DrawElementCallback(Rect rect, int index, bool isActive, bool isFoc
440443
if (_lastInvisibleElement.HasValue && index + 1 < _lastInvisibleElement.Value ||
441444
_lastVisibleElement.HasValue && index - 1 > _lastVisibleElement.Value)
442445
{
443-
return;
446+
if (index != _reorderableListGui.index)
447+
{
448+
return;
449+
}
444450
}
445451

446452
if (_reorderableListGui.count > MinElementsForVirtualization)
@@ -462,7 +468,10 @@ private void DrawElementCallback(Rect rect, int index, bool isActive, bool isFoc
462468

463469
if (rectInWindow.y < windowRect.height)
464470
{
465-
_lastVisibleElement = index;
471+
if (!_lastVisibleElement.HasValue || index > _lastVisibleElement.Value)
472+
{
473+
_lastVisibleElement = index;
474+
}
466475
}
467476
}
468477
}
@@ -488,7 +497,10 @@ private float ElementHeightCallback(int index)
488497
if (_lastInvisibleElement.HasValue && index + 1 < _lastInvisibleElement.Value ||
489498
_lastVisibleElement.HasValue && index - 1 > _lastVisibleElement.Value)
490499
{
491-
return Mathf.Max(EditorGUIUtility.singleLineHeight, GetChild(index).CachedHeight);
500+
if (index != _reorderableListGui.index)
501+
{
502+
return Mathf.Max(EditorGUIUtility.singleLineHeight, GetChild(index).CachedHeight);
503+
}
492504
}
493505

494506
return GetChild(index).GetHeight(_lastContentWidth);

0 commit comments

Comments
 (0)