@@ -87,6 +87,9 @@ public static readonly BindableProperty MenuWidthPercentageProperty
87
87
public static readonly BindableProperty MenuGestureEnabledProperty
88
88
= BindableProperty . CreateAttached ( nameof ( GetMenuGestureEnabled ) , typeof ( bool ) , typeof ( SideMenuView ) , true ) ;
89
89
90
+ public static readonly BindableProperty MainViewScaleFactorProperty
91
+ = BindableProperty . CreateAttached ( nameof ( GetMainViewScaleFactor ) , typeof ( double ) , typeof ( SideMenuView ) , 1.0 ) ;
92
+
90
93
public SideMenuView ( )
91
94
{
92
95
#region Required work-around to prevent linker from removing the platform-specific implementation
@@ -157,6 +160,12 @@ public static bool GetMenuGestureEnabled(BindableObject bindable)
157
160
public static void SetMenuGestureEnabled ( BindableObject bindable , bool value )
158
161
=> bindable . SetValue ( MenuGestureEnabledProperty , value ) ;
159
162
163
+ public static double GetMainViewScaleFactor ( BindableObject bindable )
164
+ => ( double ) bindable . GetValue ( MainViewScaleFactorProperty ) ;
165
+
166
+ public static void SetMainViewScaleFactor ( BindableObject bindable , double value )
167
+ => bindable . SetValue ( MainViewScaleFactorProperty , value ) ;
168
+
160
169
internal void OnPanUpdated ( object sender , PanUpdatedEventArgs e )
161
170
{
162
171
var shift = e . TotalX ;
@@ -364,26 +373,34 @@ SideMenuState ResolveSwipeState(bool isRightSwipe)
364
373
return isRightSwipe ? left : right ;
365
374
}
366
375
367
- bool TryUpdateShift ( double sift , bool shouldUpdatePreviousShift , bool shouldCheckMenuGestureEnabled )
376
+ bool TryUpdateShift ( double shift , bool shouldUpdatePreviousShift , bool shouldCheckMenuGestureEnabled )
368
377
{
369
- SetActiveView ( sift >= 0 ) ;
378
+ SetActiveView ( shift >= 0 ) ;
370
379
if ( activeMenu == null )
371
380
return false ;
372
381
373
382
if ( shouldCheckMenuGestureEnabled && ! GetMenuGestureEnabled ( activeMenu ) )
374
383
return false ;
375
384
376
- sift = Sign ( sift ) * Min ( Abs ( sift ) , activeMenu . Width ) ;
377
- if ( Abs ( Shift - sift ) <= double . Epsilon )
385
+ var activeMenuWidth = activeMenu . Width ;
386
+ var mainViewWidth = mainView . Width ;
387
+
388
+ shift = Sign ( shift ) * Min ( Abs ( shift ) , activeMenuWidth ) ;
389
+ if ( Abs ( Shift - shift ) <= double . Epsilon )
378
390
return false ;
379
391
380
- Shift = sift ;
381
- SetCurrentGestureState ( sift ) ;
392
+ Shift = shift ;
393
+ SetCurrentGestureState ( shift ) ;
382
394
if ( shouldUpdatePreviousShift )
383
- previousShift = sift ;
395
+ previousShift = shift ;
384
396
385
- mainView . TranslationX = sift ;
386
- overlayView . TranslationX = sift ;
397
+ using ( mainView . Batch ( ) )
398
+ {
399
+ var scale = 1 - ( ( 1 - GetMainViewScaleFactor ( activeMenu ) ) * animationEasing . Ease ( shift / activeMenuWidth ) ) ;
400
+ mainView . Scale = scale ;
401
+ mainView . TranslationX = shift - ( Sign ( shift ) * mainViewWidth * 0.5 * ( 1 - scale ) ) ;
402
+ }
403
+ overlayView . TranslationX = shift ;
387
404
return true ;
388
405
}
389
406
0 commit comments