public class ScrollOutOfBoundEventArgs : EventArgs
{
/// <summary>
- /// The bound to be scrolled out of.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public enum Bound
- {
- /// <summary>
- /// None.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- None,
-
- /// <summary>
- /// Top bound.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- Top,
-
- /// <summary>
- /// Bottom bound.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- Bottom
- }
-
- /// <summary>
/// The direction to be touched.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public enum Direction
{
/// <summary>
- /// None.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- None,
-
- /// <summary>
/// Upwards.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
/// <summary>
/// Constructor.
/// </summary>
- /// <param name="bound">Current scrollable bound</param>
/// <param name="direction">Current pan direction</param>
/// <param name="displacement">Current total displacement</param>
[EditorBrowsable(EditorBrowsableState.Never)]
- public ScrollOutOfBoundEventArgs(Bound bound, Direction direction, float displacement)
+ public ScrollOutOfBoundEventArgs(Direction direction, float displacement)
{
- ScrollableBound = bound;
PanDirection = direction;
Displacement = displacement;
}
/// <summary>
- /// Current bound of ContentContainer.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Bound ScrollableBound
- {
- get;
- }
-
- /// <summary>
/// Current pan direction of ContentContainer.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
/// <summary>
/// Current total displacement of ContentContainer.
+ /// if its value is greater than 0, it is at the top/left;
+ /// if less than 0, it is at the bottom/right.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public float Displacement
// trigger event
ScrollOutOfBoundEventArgs.Direction direction = panDisplacement > 0 ?
ScrollOutOfBoundEventArgs.Direction.Down : ScrollOutOfBoundEventArgs.Direction.Up;
- OnScrollOutOfBound(ScrollOutOfBoundEventArgs.Bound.Top, direction, totalPanDisplacement);
+ OnScrollOutOfBound(direction, totalPanDisplacement);
float newDisplacement = (int)totalPanDisplacement < (int)startShowShadowDisplacement ? 0 : totalPanDisplacement - startShowShadowDisplacement;
// trigger event
ScrollOutOfBoundEventArgs.Direction direction = panDisplacement > 0 ?
ScrollOutOfBoundEventArgs.Direction.Down : ScrollOutOfBoundEventArgs.Direction.Up;
- OnScrollOutOfBound(ScrollOutOfBoundEventArgs.Bound.Bottom, direction, totalPanDisplacement);
+ OnScrollOutOfBound(direction, totalPanDisplacement);
float newDisplacement = (int)startShowShadowDisplacement < (int)totalPanDisplacement ? 0 : startShowShadowDisplacement - totalPanDisplacement;
{
// if total displacement is 0, shadow would become invisible.
isVerticalShadowShown = false;
- OnScrollOutOfBound(ScrollOutOfBoundEventArgs.Bound.None, ScrollOutOfBoundEventArgs.Direction.None, totalPanDisplacement);
}
}
isVerticalShadowShown = false;
}
- private void OnScrollOutOfBound(ScrollOutOfBoundEventArgs.Bound bound, ScrollOutOfBoundEventArgs.Direction direction, float displacement)
+ private void OnScrollOutOfBound(ScrollOutOfBoundEventArgs.Direction direction, float displacement)
{
- ScrollOutOfBoundEventArgs args = new ScrollOutOfBoundEventArgs(bound, direction, displacement);
+ ScrollOutOfBoundEventArgs args = new ScrollOutOfBoundEventArgs(direction, displacement);
ScrollOutOfBound?.Invoke(this, args);
}
Position = new Position(300, 100),
Size = new Size(400, 300),
ScrollingDirection = Components.ScrollableBase.Direction.Vertical,
+ EnableOverShootingEffect = true,
};
mScrollableBase.ScrollOutOfBound += OnScrollOutOfBound;
private void OnScrollOutOfBound(object sender, Components.ScrollOutOfBoundEventArgs e)
{
- if (e.ScrollableBound == Components.ScrollOutOfBoundEventArgs.Bound.Top)
+ if (e.Displacement > 100)
{
- items[0].Text = "Reached at the top.";
+ if (e.PanDirection == Components.ScrollOutOfBoundEventArgs.Direction.Down)
+ {
+ items[0].Text = $"Reached at the top, panned displacement is {e.Displacement}.";
+ }
}
- else
+ else if (0 - e.Displacement > 100)
{
- items[4].Text = "Reached at the bottom.";
+ if (e.PanDirection == Components.ScrollOutOfBoundEventArgs.Direction.Up)
+ {
+ items[4].Text = $"Reached at the bottom, panned displacement is {e.Displacement}.";
+ }
}
}