17
17
18
18
namespace Windows . UI . Xaml . Controls
19
19
{
20
- public partial class ScrollContentPresenter : ContentPresenter , ICustomClippingElement , IScrollContentPresenter
20
+ public partial class ScrollContentPresenter : ContentPresenter , ICustomClippingElement
21
21
{
22
22
// Default physical amount to scroll with Up/Down/Left/Right key
23
23
const double ScrollViewerLineDelta = 16.0 ;
@@ -92,19 +92,9 @@ public object ScrollOwner
92
92
}
93
93
private ScrollViewer Scroller => ScrollOwner as ScrollViewer ;
94
94
95
- public ScrollMode HorizontalScrollMode { get ; set ; }
95
+ public bool CanHorizontallyScroll { get ; set ; }
96
96
97
- public ScrollMode VerticalScrollMode { get ; set ; }
98
-
99
- public float MinimumZoomScale { get ; set ; }
100
-
101
- public float MaximumZoomScale { get ; set ; }
102
-
103
- ScrollBarVisibility IScrollContentPresenter . VerticalScrollBarVisibility { get => VerticalScrollBarVisibility ; set => VerticalScrollBarVisibility = value ; }
104
- internal ScrollBarVisibility VerticalScrollBarVisibility { get ; set ; }
105
-
106
- ScrollBarVisibility IScrollContentPresenter . HorizontalScrollBarVisibility { get => HorizontalScrollBarVisibility ; set => HorizontalScrollBarVisibility = value ; }
107
- internal ScrollBarVisibility HorizontalScrollBarVisibility { get ; set ; }
97
+ public bool CanVerticallyScroll { get ; set ; }
108
98
109
99
public double HorizontalOffset { get ; private set ; }
110
100
@@ -126,7 +116,8 @@ public ScrollContentPresenter()
126
116
PointerWheelChanged += ScrollContentPresenter_PointerWheelChanged ;
127
117
128
118
// Touch scroll support
129
- ManipulationMode = ManipulationModes . TranslateX | ManipulationModes . TranslateY ;
119
+ ManipulationMode = ManipulationModes . TranslateX | ManipulationModes . TranslateY ; // Updated in PrepareTouchScroll!
120
+ ManipulationStarting += PrepareTouchScroll ;
130
121
ManipulationStarted += BeginTouchScroll ;
131
122
ManipulationDelta += UpdateTouchScroll ;
132
123
ManipulationCompleted += CompleteTouchScroll ;
@@ -158,6 +149,10 @@ protected override void OnContentChanged(object oldValue, object newValue)
158
149
}
159
150
}
160
151
152
+ internal void OnMinZoomFactorChanged ( float newValue ) { }
153
+
154
+ internal void OnMaxZoomFactorChanged ( float newValue ) { }
155
+
161
156
internal bool Set (
162
157
double ? horizontalOffset = null ,
163
158
double ? verticalOffset = null ,
@@ -232,12 +227,12 @@ private void ScrollContentPresenter_PointerWheelChanged(object sender, Input.Poi
232
227
233
228
if ( Content is UIElement )
234
229
{
235
- var canScrollHorizontally = HorizontalScrollBarVisibility != ScrollBarVisibility . Disabled ;
236
- var canScrollVertically = VerticalScrollBarVisibility != ScrollBarVisibility . Disabled ;
230
+ var canScrollHorizontally = CanHorizontallyScroll ;
231
+ var canScrollVertically = CanVerticallyScroll ;
237
232
238
233
if ( e . KeyModifiers == VirtualKeyModifiers . Control )
239
234
{
240
- // TODO: Handle zoom
235
+ // TODO: Handle zoom https://github.com/unoplatform/uno/issues/4309
241
236
}
242
237
else if ( ! canScrollVertically || properties . IsHorizontalMouseWheel || e . KeyModifiers == VirtualKeyModifiers . Shift )
243
238
{
@@ -253,6 +248,19 @@ private void ScrollContentPresenter_PointerWheelChanged(object sender, Input.Poi
253
248
}
254
249
}
255
250
251
+ private void PrepareTouchScroll ( object sender , ManipulationStartingRoutedEventArgs e )
252
+ {
253
+ if ( ! CanVerticallyScroll || ExtentHeight <= 0 )
254
+ {
255
+ e . Mode &= ~ ManipulationModes . TranslateY ;
256
+ }
257
+
258
+ if ( ! CanHorizontallyScroll || ExtentWidth <= 0 )
259
+ {
260
+ e . Mode &= ~ ManipulationModes . TranslateX ;
261
+ }
262
+ }
263
+
256
264
private void BeginTouchScroll ( object sender , ManipulationStartedRoutedEventArgs e )
257
265
{
258
266
if ( e . PointerDeviceType != PointerDeviceType . Touch )
0 commit comments