@@ -226,7 +226,8 @@ private void ParallaxGrid_OffsetReset()
226226 _parallaxGridVisual ,
227227 Vector3 . Zero ,
228228 Vector3 . One ,
229- 250d ) ;
229+ 250d ,
230+ easingFunction : _parallaxEasingFunction ) ;
230231 }
231232
232233 private void ParallaxGrid_OnPointerMoved ( object sender , PointerRoutedEventArgs e )
@@ -248,8 +249,7 @@ private void ParallaxGrid_OnPointerMoved(object sender, PointerRoutedEventArgs e
248249 double offsetX = ParallaxHorizontalShift ;
249250 double offsetY = ParallaxVerticalShift ;
250251
251- bool isHighRefreshRate = WindowUtility . CurrentWindowMonitorRefreshRate > 75000 / 1001 ;
252- double dur = isHighRefreshRate ? 40 : 10 ;
252+ double deltaMs = Math . Max ( 1000d / WindowUtility . CurrentWindowMonitorRefreshRate , 8d ) ;
253253
254254 StartElementOffsetAnimation ( _parallaxGridCompositor ,
255255 _parallaxGridVisual ,
@@ -258,8 +258,8 @@ private void ParallaxGrid_OnPointerMoved(object sender, PointerRoutedEventArgs e
258258 offsetY ,
259259 nx ,
260260 ny ,
261- dur ,
262- ! isHighRefreshRate ) ;
261+ deltaMs ,
262+ easingFunction : _parallaxEasingFunction ) ;
263263 }
264264
265265 private static void StartElementOffsetAnimation (
@@ -324,24 +324,28 @@ private static void StartElementElevateEasingAnimation(
324324 return ;
325325 }
326326
327- CompositionAnimationGroup ? animGroup = compositor . CreateAnimationGroup ( ) ;
328-
329327 // Move
330- Vector3KeyFrameAnimation ? anim = compositor . CreateVector3KeyFrameAnimation ( ) ;
331- anim . Duration = TimeSpan . FromMilliseconds ( duration ) ;
332- anim . InsertKeyFrame ( 1f , offset , easingFunction ) ;
333- anim . Target = targetTranslation ;
328+ Vector3KeyFrameAnimation anim = CreateVector3Keyframe ( offset , targetTranslation ) ;
334329
335330 // Scale
336- Vector3KeyFrameAnimation ? scaleAnim = compositor . CreateVector3KeyFrameAnimation ( ) ;
337- scaleAnim . Duration = TimeSpan . FromMilliseconds ( duration ) ;
338- scaleAnim . InsertKeyFrame ( 1f , scale , easingFunction ) ;
339- scaleAnim . Target = targetScale ;
331+ Vector3KeyFrameAnimation scaleAnim = CreateVector3Keyframe ( scale , targetScale ) ;
340332
341- animGroup . Add ( anim ) ;
342- animGroup . Add ( scaleAnim ) ;
333+ visual . StartAnimation ( targetTranslation , anim ) ;
334+ visual . StartAnimation ( targetScale , scaleAnim ) ;
343335
344- visual . StartAnimationGroup ( animGroup ) ;
336+ return ;
337+
338+ Vector3KeyFrameAnimation CreateVector3Keyframe (
339+ Vector3 valueTo ,
340+ string targetProperty )
341+ {
342+ Vector3KeyFrameAnimation keyframe = compositor . CreateVector3KeyFrameAnimation ( ) ;
343+ keyframe . InsertKeyFrame ( 1 , valueTo , easingFunction ) ;
344+ keyframe . Target = targetProperty ;
345+ keyframe . Duration = TimeSpan . FromMilliseconds ( duration ) ;
346+
347+ return keyframe ;
348+ }
345349 }
346350
347351 private static void StartElementElevateSpringAnimation (
@@ -364,18 +368,18 @@ private static void StartElementElevateSpringAnimation(
364368
365369 // Move
366370 SpringVector3NaturalMotionAnimation ? anim = compositor . CreateSpringVector3Animation ( ) ;
367- anim . Period = TimeSpan . FromMilliseconds ( duration ) ;
368- anim . FinalValue = offset ;
369- anim . DampingRatio = 1f ;
370- anim . Target = targetTranslation ;
371+ anim . Period = TimeSpan . FromMilliseconds ( duration ) ;
372+ anim . FinalValue = offset ;
373+ anim . DampingRatio = 1f ;
374+ anim . Target = targetTranslation ;
371375 anim . DelayBehavior = AnimationDelayBehavior . SetInitialValueBeforeDelay ;
372376
373377 // Scale
374378 SpringVector3NaturalMotionAnimation ? scaleAnim = compositor . CreateSpringVector3Animation ( ) ;
375- scaleAnim . Period = TimeSpan . FromMilliseconds ( duration ) ;
376- scaleAnim . FinalValue = scale ;
377- scaleAnim . DampingRatio = 1f ;
378- scaleAnim . Target = targetScale ;
379+ scaleAnim . Period = TimeSpan . FromMilliseconds ( duration ) ;
380+ scaleAnim . FinalValue = scale ;
381+ scaleAnim . DampingRatio = 1f ;
382+ scaleAnim . Target = targetScale ;
379383 scaleAnim . DelayBehavior = AnimationDelayBehavior . SetInitialValueBeforeDelay ;
380384
381385 animGroup . Add ( anim ) ;
@@ -475,8 +479,7 @@ private void ElevateGrid_UpdateElevationSize(bool enable)
475479 0d ,
476480 500d ,
477481 false ,
478- CompositionEasingFunction . CreateCircleEasingFunction ( _elevateGridCompositor ,
479- CompositionEasingFunctionMode . Out ) ) ;
482+ _elevateEasingFunction ) ;
480483 }
481484
482485 #endregion
0 commit comments