@@ -7,15 +7,15 @@ namespace Reactive.Components;
77public enum ScrollUpdateType {
88 None ,
99 /// User intent to scroll (e.g. ScrollPos, ScrollItem).
10- Intent ,
10+ Intent ,
1111 /// Controller measurements (e.g. ContentSize, ViewSize).
12- Measurements ,
12+ Measurements ,
1313 /// Controller scroll (ActualScrollPos).
1414 Scroll ,
1515 /// <summary>
1616 /// Controller scroll has just finished.
1717 /// </summary>
18- ScrollCompleted
18+ ScrollFinished
1919}
2020
2121[ PublicAPI ]
@@ -25,13 +25,6 @@ public class ScrollContext : IState<ScrollContext> {
2525 /// </summary>
2626 public float ScrollPos { get ; private set ; }
2727
28- /// <summary>
29- /// Determines the item that the controller should scroll to.
30- /// Has higher priority than <see cref="ScrollPos"/>, so if both are specified the first one is ignored.
31- /// Defaults to <see cref="ScrollPos"/> if the specified object isn't presented in the view.
32- /// </summary>
33- public object ? ScrollItem { get ; private set ; }
34-
3528 /// Whether the scroll animation should finish immediately. Set by the user.
3629 public bool Immediately { get ; private set ; }
3730
@@ -46,7 +39,7 @@ public class ScrollContext : IState<ScrollContext> {
4639 /// Set by a component controlling the view.
4740 /// </summary>
4841 public float LineSize { get ; private set ; }
49-
42+
5043 /// <summary>
5144 /// The size of the scroll content. Set by a component controlling the view.
5245 /// </summary>
@@ -56,7 +49,7 @@ public class ScrollContext : IState<ScrollContext> {
5649 /// The size of the viewport. Set by a component controlling the view.
5750 /// </summary>
5851 public float ViewSize { get ; private set ; }
59-
52+
6053 /// <summary>
6154 /// Determines a kind of the last update. Returns None if called outside the ValueChanged cycle.
6255 /// </summary>
@@ -68,7 +61,7 @@ public class ScrollContext : IState<ScrollContext> {
6861 public float NormalizedScrollPos {
6962 get => Mathf . Clamp01 ( ActualScrollPos / MaxScrollPos ) ;
7063 }
71-
64+
7265 public float NormalizedPageHeight {
7366 get => Mathf . Clamp01 ( ViewSize / ContentSize ) ;
7467 }
@@ -90,7 +83,7 @@ public bool CanScroll {
9083 // in the future, so moved into a separate property
9184 get => ContentSize > ViewSize ;
9285 }
93-
86+
9487 /// <summary>
9588 /// Scrolls to the specified point.
9689 /// </summary>
@@ -99,30 +92,17 @@ public bool CanScroll {
9992 /// <returns>An updated context.</returns>
10093 public void ScrollTo ( float pos , bool immediately = false ) {
10194 var newPos = Mathf . Clamp ( pos , 0f , MaxScrollPos ) ;
102-
95+
10396 if ( Mathf . Approximately ( newPos , ScrollPos ) ) {
10497 return ;
10598 }
10699
107100 ScrollPos = newPos ;
108- ScrollItem = null ;
109101 Immediately = immediately ;
110-
111- NotifyValueChanged ( ScrollUpdateType . Intent ) ;
112- }
113102
114- /// <summary>
115- /// Scrolls to the specified item. Defaults
116- /// </summary>
117- /// <param name="pos">The position to scroll to.</param>
118- /// <param name="immediately">Whether to apply the scroll immediately.</param>
119- /// <returns>An updated context.</returns>
120- public void ScrollTo ( object item , bool immediately = false ) {
121- ScrollItem = item ;
122- Immediately = immediately ;
123103 NotifyValueChanged ( ScrollUpdateType . Intent ) ;
124104 }
125-
105+
126106 public void ScrollRelative ( float offset , bool immediately = false ) {
127107 ScrollTo ( ScrollPos + offset , immediately ) ;
128108 }
@@ -148,7 +128,7 @@ public void LineDown(bool immediately = false) {
148128 }
149129
150130 public void LineUp ( bool immediately = false ) {
151- ScrollRelative ( LineSize , immediately ) ;
131+ ScrollRelative ( LineSize * - 1 , immediately ) ;
152132 }
153133
154134 /// <summary>
@@ -171,13 +151,13 @@ public void ControllerSetScrollPos(float pos) {
171151 if ( Mathf . Approximately ( ActualScrollPos , pos ) ) {
172152 return ;
173153 }
174-
154+
175155 ActualScrollPos = pos ;
176156 NotifyValueChanged ( ScrollUpdateType . Scroll ) ;
177157 }
178158
179159 public void ControllerNotifyScrollCompleted ( ) {
180- NotifyValueChanged ( ScrollUpdateType . ScrollCompleted ) ;
160+ NotifyValueChanged ( ScrollUpdateType . ScrollFinished ) ;
181161 }
182162
183163 #region State Impl
@@ -189,10 +169,10 @@ public void ControllerNotifyScrollCompleted() {
189169
190170 private void NotifyValueChanged ( ScrollUpdateType type ) {
191171 UpdateType = type ;
192-
172+
193173 ValueChangedEvent ? . Invoke ( this ) ;
194174 StateUpdatedEvent ? . Invoke ( ) ;
195-
175+
196176 UpdateType = ScrollUpdateType . None ;
197177 }
198178
0 commit comments