public MainPage() { this.InitializeComponent(); _rootContainer = ElementCompositionPreview.GetElementVisual(this); _panelContainer = ElementCompositionPreview.GetElementVisual(navBarPanel); _compositor = _rootContainer.Compositor; _scrollInteractionSource = InitializeScrollInteractionSource(); _tracker = InitializeTracker(); InitializeSnapAnimationModifiers(); InitializePanAnimation(); _openAnimation = _compositor.CreateSpringVector3Animation(); _openAnimation.DampingRatio = 0.75f; _openAnimation.FinalValue = new Vector3(0, openSize, 0); _openAnimation.Period = TimeSpan.FromSeconds(0.05f); Elements.Add(0); Elements.Add(0); Elements.Add(0); Elements.Add(0); Elements.Add(0); Elements.Add(0); }
private void CreateOrUpdateSpringAnimation(float finalValue) { if (_SpringAnimation == null) { _SpringAnimation = _Compositor.CreateSpringVector3Animation(); _SpringAnimation.Target = "Scale"; } _SpringAnimation.FinalValue = new Vector3(finalValue); }
private void AddImplicitAnimation_OnClick(object sender, RoutedEventArgs e) { Visual visual = ElementCompositionPreview.GetElementVisual(Rectangle); SpringVector3NaturalMotionAnimation animation = SpringVector3NaturalMotionAnimation(visual.Compositor); animation.Target = nameof(Visual.Scale); ElementCompositionPreview.SetImplicitShowAnimation(Rectangle, animation); ElementCompositionPreview.SetImplicitHideAnimation(Rectangle, animation); }
//check private void CreateOrUpdateSpringAnimation(float finalValue) { if (_springAnimation == null) { _springAnimation = _compositor.CreateSpringVector3Animation(); _springAnimation.Target = "Scale"; } _springAnimation.FinalValue = new System.Numerics.Vector3(finalValue); }
private static SpringVector3NaturalMotionAnimation SpringVector3NaturalMotionAnimation(Compositor compositor) { SpringVector3NaturalMotionAnimation animation = compositor.CreateSpringVector3Animation(); animation.Period = TimeSpan.FromMilliseconds(60); animation.DampingRatio = 0.6f; animation.InitialValue = Vector3.Zero; animation.FinalValue = Vector3.One; return(animation); }
private void SpringVector3NaturalMotionAnimation_OnClick(object sender, RoutedEventArgs e) { Visual visual = ElementCompositionPreview.GetElementVisual(Rectangle); Compositor compositor = visual.Compositor; SpringVector3NaturalMotionAnimation animation = SpringVector3NaturalMotionAnimation(compositor); visual.StartAnimation(nameof(Visual.Scale), animation); }
private void CreateOrUpdateSpringAnimation(float finalValue) { if (SpringAnimation == null) { SpringAnimation = Comp.CreateSpringVector3Animation(); SpringAnimation.Target = "Scale"; } SpringAnimation.FinalValue = new Vector3(finalValue); }
private void UpdateSpringAnimation(float finalValue) { if (_springAnimation == null) { _springAnimation = _compositor.CreateSpringVector3Animation(); _springAnimation.Target = "Scale"; } _springAnimation.FinalValue = new Vector3(finalValue); _springAnimation.DampingRatio = GetDampingRatio(); _springAnimation.Period = GetPeriod(); }
private void CreateOrUpdateSpringAnimation(float finalValue) { if (_springAnimation == null) { _springAnimation = _compositor.CreateSpringVector3Animation(); _springAnimation.Target = "Scale"; } _springAnimation.FinalValue = new Vector3(finalValue); _springAnimation.DampingRatio = 0.4f; _springAnimation.Period = TimeSpan.FromMilliseconds(50d); }
public static void CreateOrUpdateSpringAnimation(float finalValue) { if (_prdAnimation == null) { if (_compositor == null) { _compositor = Window.Current.Compositor; } _prdAnimation = _compositor.CreateSpringVector3Animation(); _prdAnimation.Target = "Scale"; } _prdAnimation.FinalValue = new Vector3(1.0f, finalValue, finalValue); }
private void CreateOrUpdateSpringAnimation(float finalValue) { if (m_springAnimation is null) { // In WinUI3, the Compositor is exposed by the Window object. // Make sure "this" references to the Window Compositor compositor = this.Compositor; if (compositor is not null) { m_springAnimation = compositor.CreateSpringVector3Animation(); m_springAnimation.Target = "Scale"; } } m_springAnimation.FinalValue = new Vector3(finalValue); }
public MainPage() { this.InitializeComponent(); this.Loaded += (_, __) => { _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor; ElementCompositionPreview.SetIsTranslationEnabled(MoveableRectangle, true); _springLeftAnimation = _compositor.CreateSpringVector3Animation(); _springLeftAnimation.Period = TimeSpan.FromMilliseconds(30); _springLeftAnimation.DampingRatio = 0.5f; _springLeftAnimation.FinalValue = new Vector3(-300, 0, 0); _springRightAnimation = _compositor.CreateSpringVector3Animation(); _springRightAnimation.Period = TimeSpan.FromMilliseconds(30); _springRightAnimation.DampingRatio = 0.5f; _springRightAnimation.FinalValue = new Vector3(0, 0, 0); _springRightABitAnimation = _compositor.CreateSpringVector3Animation(); _springRightABitAnimation.Period = TimeSpan.FromMilliseconds(30); _springRightABitAnimation.DampingRatio = 0.5f; _springRightABitAnimation.FinalValue = new Vector3(-1, 0, 0); }; MoveLeftButton.Click += (_, __) => { ElementCompositionPreview.GetElementVisual(MoveableRectangle).StartAnimation("Translation", _springLeftAnimation); }; MoveRightButton.Click += (_, __) => { ElementCompositionPreview.GetElementVisual(MoveableRectangle).StartAnimation("Translation", _springRightAnimation); }; MoveRightABitButton.Click += (_, __) => { ElementCompositionPreview.GetElementVisual(MoveableRectangle).StartAnimation("Translation", _springRightABitAnimation); }; }
public static SpringVector3NaturalMotionAnimation SetPeriod(this SpringVector3NaturalMotionAnimation animation, TimeSpan duration) { animation.Period = duration; return animation; }
public static SpringVector3NaturalMotionAnimation SetPeriod(this SpringVector3NaturalMotionAnimation animation, double duration) { return SetPeriod(animation, TimeSpan.FromSeconds(duration)); }