Пример #1
0
        private void ConfigureRestingPoints()
        {
            // Setup a possible inertia endpoint (snap point) for the InteractionTracker's minimum position
            var endpoint1 = InteractionTrackerInertiaRestingValue.Create(_compositor);

            // Use this endpoint when the natural resting position of the interaction is less than the halfway point
            var trackerTarget = ExpressionValues.Target.CreateInteractionTrackerTarget();

            endpoint1.SetCondition(EF.Abs(trackerTarget.NaturalRestingPosition.X - (itemsRendered.SelectedIndex * _itemWidth)) < p * _itemWidth);
            endpoint1.SetRestingValue(trackerTarget.MinPosition.X + _itemWidth);

            // Setup a possible inertia endpoint (snap point) for the InteractionTracker's maximum position
            var endpoint2 = InteractionTrackerInertiaRestingValue.Create(_compositor);

            endpoint2.SetCondition(trackerTarget.NaturalRestingPosition.X - (itemsRendered.SelectedIndex * _itemWidth) >= p * _itemWidth);
            endpoint2.SetRestingValue(trackerTarget.MaxPosition.X);

            // Setup a possible inertia endpoint (snap point) for the InteractionTracker's maximum position
            var endpoint3 = InteractionTrackerInertiaRestingValue.Create(_compositor);

            endpoint3.SetCondition(trackerTarget.NaturalRestingPosition.X - (itemsRendered.SelectedIndex * _itemWidth) <= -(p * _itemWidth));
            endpoint3.SetRestingValue(trackerTarget.MinPosition.X);

            _tracker.ConfigurePositionXInertiaModifiers(new InteractionTrackerInertiaModifier[] { endpoint1, endpoint2, endpoint3 });
        }
Пример #2
0
        private void InitializeAnimations()
        {
            _props.InsertScalar("position", 0);
            _props.InsertScalar("progress", 0);

            var trackerNode = _tracker.GetReference();

            _props.StartAnimation("position", -trackerNode.Position.X);
            _props.StartAnimation("progress", EF.Abs(trackerNode.Position.X) / trackerNode.MaxPosition.X);

            ConfigureTemplateAnimations();
        }
Пример #3
0
        private void ConfigureTemplateAnimations()
        {
            var propSetProgress = _props.GetReference().GetScalarProperty("progress");
            var trackerNode     = _tracker.GetReference();

            foreach (var itemRendered in itemsRendered.Items)
            {
                var template = itemRendered.Item2;

                template.GetVisual().StopAnimation("offset.x");
                template.GetVisual().StopAnimation("Scale");

                template.GetVisual().StartAnimation("offset.x", _props.GetReference().GetScalarProperty("position") + itemRendered.Item1 * _itemWidth);

                float positionCenter = (itemRendered.Item1 * _itemWidth);
                float position       = (itemRendered.Item1 * _itemWidth) - _itemWidth / 2;
                float positionEnd    = (itemRendered.Item1 * _itemWidth) + _itemWidth / 2;

                template.GetVisual()
                .StartAnimation("Scale",
                                EF.Vector3(1, 1, 1) * EF.Conditional(trackerNode.Position.X > position & trackerNode.Position.X < positionEnd
                                                                     , EF.Lerp(1.2f, 1, EF.Abs(positionCenter - trackerNode.Position.X) / (_itemWidth / 2))
                                                                     , 1));


                template.BackgroundPanel
                .StartAnimation("Scale",
                                EF.Vector3(1, 1, 1) * EF.Conditional(trackerNode.Position.X > position & trackerNode.Position.X < positionEnd
                                                                     , EF.Lerp(1.1f, 1, EF.Abs(positionCenter - trackerNode.Position.X) / (_itemWidth / 2))
                                                                     , 1));

                template.Shadow
                .StartAnimation("opacity",
                                EF.Conditional(trackerNode.Position.X > position & trackerNode.Position.X < positionEnd
                                               , EF.Lerp(1, 0, EF.Abs(positionCenter - trackerNode.Position.X) / (_itemWidth / 2))
                                               , 0));

                template.ContentPanel
                .StartAnimation("opacity",
                                EF.Conditional(trackerNode.Position.X > position & trackerNode.Position.X < positionEnd
                                               , EF.Lerp(1, 0, EF.Abs(positionCenter - trackerNode.Position.X) / (_itemWidth / 2))
                                               , 0));

                template.OverlayPanel
                .StartAnimation("opacity",
                                EF.Conditional(trackerNode.Position.X > position & trackerNode.Position.X < positionEnd
                                               , EF.Lerp(0, 0.6f, EF.Abs(positionCenter - trackerNode.Position.X) / (_itemWidth / 2))
                                               , 0.6f));
            }
        }
Пример #4
0
        private void SetupLayerAnimations(Layer layer, float layerZ)
        {
            var layerVisual         = layer.LayerVisual;
            var itemContainerVisual = layer.ItemContainerVisual;

            var compositor   = layerVisual.Compositor;
            var currentZNode = _animationPropertySet.GetReference().GetScalarProperty("currentZ");

            // Opacity and saturation go to zero with as |deltaZ| -> 1
            var opacityAndSaturationExpression = EF.Max(0, 1 - EF.Abs(currentZNode - layerZ));

            layerVisual.StartAnimation(nameof(layerVisual.Opacity), opacityAndSaturationExpression);
            layerVisual.Effect.Properties.StartAnimation("saturation.Saturation", opacityAndSaturationExpression);

            // Scale changes with deltaZ (perspective-like)
            var scaleExpression = EF.Vector3(EF.Pow(1.5f, currentZNode - layerZ), EF.Pow(1.5f, currentZNode - layerZ), 0);

            itemContainerVisual.StartAnimation(nameof(layerVisual.Scale), scaleExpression);

            // Blur increases with |deltaZ|
            var blurAmountExpression = EF.Abs(currentZNode - layerZ) * 10;

            layerVisual.Effect.Properties.StartAnimation("blur.BlurAmount", blurAmountExpression);
        }