private UpdateObscuredViewVisibility ( ) : void | ||
return | void |
private void UpdateObscuredViewVisibility()
{
if (ChildCount == 0) return;
var leftBound = PaddingLeft;
var rightBound = Width - PaddingLeft;
var topBound = PaddingTop;
var bottomBound = Height - PaddingBottom;
int left;
int right;
int top;
int bottom;
if (_slideableView != null && HasOpaqueBackground(_slideableView))
{
left = _slideableView.Left;
right = _slideableView.Right;
top = _slideableView.Top;
bottom = _slideableView.Bottom;
}
else
left = right = top = bottom = 0;
var child = GetChildAt(0);
var clampedChildLeft = Math.Max(leftBound, child.Left);
var clampedChildTop = Math.Max(topBound, child.Top);
var clampedChildRight = Math.Max(rightBound, child.Right);
var clampedChildBottom = Math.Max(bottomBound, child.Bottom);
ViewStates vis;
if (clampedChildLeft >= left && clampedChildTop >= top &&
clampedChildRight <= right && clampedChildBottom <= bottom)
vis = ViewStates.Invisible;
else
vis = ViewStates.Visible;
child.Visibility = vis;
}
public override void OnViewDragStateChanged(int state) { var anchoredTop = (int)(_panelLayout._anchorPoint * _panelLayout._slideRange); if (_panelLayout._dragHelper.ViewDragState == ViewDragHelper.StateIdle) { if (FloatNearlyEqual(_panelLayout._slideOffset, 0)) { if (_panelLayout._slideState != SlideState.Expanded) { _panelLayout.UpdateObscuredViewVisibility(); _panelLayout.OnPanelExpanded(_panelLayout._slideableView); _panelLayout._slideState = SlideState.Expanded; } } else if (FloatNearlyEqual(_panelLayout._slideOffset, (float)anchoredTop / _panelLayout._slideRange)) { if (_panelLayout._slideState != SlideState.Anchored) { _panelLayout.UpdateObscuredViewVisibility(); _panelLayout.OnPanelAnchored(_panelLayout._slideableView); _panelLayout._slideState = SlideState.Anchored; } } else if (_panelLayout._slideState != SlideState.Collapsed) { _panelLayout.OnPanelCollapsed(_panelLayout._slideableView); _panelLayout._slideState = SlideState.Collapsed; } } }