@@ -489,6 +489,19 @@ public partial class SfBottomSheet : SfView, IParentThemeElement
489
489
BindingMode . Default
490
490
) ;
491
491
492
+ /// <summary>
493
+ /// Identifies the <see cref="AnimationDuration"/> bindable property.
494
+ /// </summary>
495
+ /// <value>
496
+ /// The identifier for <see cref="AnimationDuration"/> bindable property.
497
+ /// </value>
498
+ public static readonly BindableProperty AnimationDurationProperty = BindableProperty . Create (
499
+ nameof ( AnimationDuration ) ,
500
+ typeof ( double ) ,
501
+ typeof ( SfBottomSheet ) ,
502
+ 150d ,
503
+ BindingMode . Default ) ;
504
+
492
505
#endregion
493
506
494
507
#region Internal Bindable Properties
@@ -1183,6 +1196,19 @@ public bool CollapseOnOverlayTap
1183
1196
set => SetValue ( CollapseOnOverlayTapProperty , value ) ;
1184
1197
}
1185
1198
1199
+ /// <summary>
1200
+ /// Gets or sets a value that can be used to adjust the duration of the opening and closing animations.
1201
+ /// </summary>
1202
+ /// <value>
1203
+ /// It accepts double values, and the default value is 150ms.
1204
+ /// </value>
1205
+
1206
+ public double AnimationDuration
1207
+ {
1208
+ get => ( double ) GetValue ( AnimationDurationProperty ) ;
1209
+ set => SetValue ( AnimationDurationProperty , value ) ;
1210
+ }
1211
+
1186
1212
#endregion
1187
1213
1188
1214
#region Internal Properties
@@ -1256,6 +1282,14 @@ public void Close()
1256
1282
}
1257
1283
}
1258
1284
1285
+ /// <summary>
1286
+ /// Updates the animation duration with the given value.
1287
+ /// </summary>
1288
+ int SetAnimationDuration ( )
1289
+ {
1290
+ return ( int ) Math . Max ( 0 , AnimationDuration ) ;
1291
+ }
1292
+
1259
1293
#endregion
1260
1294
1261
1295
#region Internal Methods
@@ -2093,13 +2127,13 @@ void AnimateBottomSheet(double targetPosition, Action? onFinish = null)
2093
2127
_overlayGrid . AbortAnimation ( "overlayGridAnimation" ) ;
2094
2128
}
2095
2129
2096
- const int animationDuration = 150 ;
2097
- const int topPadding = 2 ;
2130
+ int animationDuration = this . SetAnimationDuration ( ) ;
2131
+ const int topPadding = 2 ;
2098
2132
_isSheetOpen = true ;
2099
2133
if ( _bottomSheet is not null )
2100
2134
{
2101
2135
var bottomSheetAnimation = new Animation ( d => _bottomSheet . TranslationY = d , _bottomSheet . TranslationY , targetPosition + topPadding ) ;
2102
- _bottomSheet ? . Animate ( "bottomSheetAnimation" , bottomSheetAnimation , length : animationDuration , easing : Easing . Linear , finished : ( v , e ) =>
2136
+ _bottomSheet ? . Animate ( "bottomSheetAnimation" , bottomSheetAnimation , length : ( uint ) animationDuration , easing : Easing . Linear , finished : ( v , e ) =>
2103
2137
{
2104
2138
UpdateBottomSheetHeight ( ) ;
2105
2139
onFinish ? . Invoke ( ) ;
@@ -2133,7 +2167,14 @@ void AnimateOverlay(int animationDuration)
2133
2167
endValue = DefaultOverlayOpacity ;
2134
2168
}
2135
2169
2136
- var overlayGridAnimation = new Animation ( d => _overlayGrid . Opacity = d , startValue , endValue ) ;
2170
+ var overlayGridAnimation = new Animation ( d =>
2171
+ {
2172
+ if ( ! double . IsNaN ( d ) )
2173
+ {
2174
+ _overlayGrid . Opacity = d ;
2175
+ }
2176
+ }
2177
+ , startValue , endValue ) ;
2137
2178
_overlayGrid . Animate ( "overlayGridAnimation" , overlayGridAnimation ,
2138
2179
length : ( uint ) animationDuration ,
2139
2180
easing : Easing . Linear ,
0 commit comments