From 04e1225ff978c120e76b12a77a22767098ed1ab2 Mon Sep 17 00:00:00 2001 From: "huayong.xu" Date: Fri, 27 Nov 2020 10:27:55 +0800 Subject: [PATCH] Update sample of ScrollableBase OutOfBound event handler. --- .../Controls/ScrollableBase.cs | 55 +++------------------- .../Samples/ScrollableBaseOutOfBoundSample.cs | 15 ++++-- 2 files changed, 18 insertions(+), 52 deletions(-) diff --git a/src/Tizen.NUI.Components/Controls/ScrollableBase.cs b/src/Tizen.NUI.Components/Controls/ScrollableBase.cs index 9124993..e5fe965 100755 --- a/src/Tizen.NUI.Components/Controls/ScrollableBase.cs +++ b/src/Tizen.NUI.Components/Controls/ScrollableBase.cs @@ -62,43 +62,12 @@ namespace Tizen.NUI.Components public class ScrollOutOfBoundEventArgs : EventArgs { /// - /// The bound to be scrolled out of. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public enum Bound - { - /// - /// None. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - None, - - /// - /// Top bound. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - Top, - - /// - /// Bottom bound. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - Bottom - } - - /// /// The direction to be touched. /// [EditorBrowsable(EditorBrowsableState.Never)] public enum Direction { /// - /// None. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - None, - - /// /// Upwards. /// [EditorBrowsable(EditorBrowsableState.Never)] @@ -114,27 +83,16 @@ namespace Tizen.NUI.Components /// /// Constructor. /// - /// Current scrollable bound /// Current pan direction /// Current total displacement [EditorBrowsable(EditorBrowsableState.Never)] - public ScrollOutOfBoundEventArgs(Bound bound, Direction direction, float displacement) + public ScrollOutOfBoundEventArgs(Direction direction, float displacement) { - ScrollableBound = bound; PanDirection = direction; Displacement = displacement; } /// - /// Current bound of ContentContainer. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public Bound ScrollableBound - { - get; - } - - /// /// Current pan direction of ContentContainer. /// [EditorBrowsable(EditorBrowsableState.Never)] @@ -145,6 +103,8 @@ namespace Tizen.NUI.Components /// /// 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. /// [EditorBrowsable(EditorBrowsableState.Never)] public float Displacement @@ -1125,7 +1085,7 @@ namespace Tizen.NUI.Components // 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; @@ -1152,7 +1112,7 @@ namespace Tizen.NUI.Components // 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; @@ -1167,7 +1127,6 @@ namespace Tizen.NUI.Components { // if total displacement is 0, shadow would become invisible. isVerticalShadowShown = false; - OnScrollOutOfBound(ScrollOutOfBoundEventArgs.Bound.None, ScrollOutOfBoundEventArgs.Direction.None, totalPanDisplacement); } } @@ -1217,9 +1176,9 @@ namespace Tizen.NUI.Components 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); } diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ScrollableBaseOutOfBoundSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ScrollableBaseOutOfBoundSample.cs index 08fa5e4..390bbfd 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ScrollableBaseOutOfBoundSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/ScrollableBaseOutOfBoundSample.cs @@ -35,6 +35,7 @@ namespace Tizen.NUI.Samples Position = new Position(300, 100), Size = new Size(400, 300), ScrollingDirection = Components.ScrollableBase.Direction.Vertical, + EnableOverShootingEffect = true, }; mScrollableBase.ScrollOutOfBound += OnScrollOutOfBound; @@ -63,13 +64,19 @@ namespace Tizen.NUI.Samples 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}."; + } } } -- 2.7.4