public override void Update()
        {
            AnimatedNode toValue = _manager.GetNodeById(_toValueNode);

            _animationConfig["toValue"] = ((ValueAnimatedNode)toValue).Value;
            _manager.StartAnimatingNode(_animationId, _valueNode, _animationConfig, null);
        }
Esempio n. 2
0
        public void UpdateView()
        {
            if (_connectedViewTag == -1)
            {
                return;
            }

            foreach (var entry in _propNodeMapping)
            {
                var node = _manager.GetNodeById(entry.Value);
                if (node is StyleAnimatedNode styleNode)
                {
                    styleNode.CollectViewUpdates(_propMap);
                }
                else if (node is ValueAnimatedNode valueNode)
                {
                    _propMap[entry.Key] = valueNode.Value;
                }
                else
                {
                    throw new InvalidOperationException(
                              Invariant($"Unsupported type of node used in property node '{node.GetType()}'."));
                }
            }

            var updated = _uiImplementation.SynchronouslyUpdateViewOnDispatcherThread(
                _connectedViewTag,
                _diffMap);

            if (!updated)
            {
                Tracer.Error(ReactConstants.Tag, "Native animation workaround, frame lost as result of race condition.", null);
            }
        }
Esempio n. 3
0
        public override void Update()
        {
            for (int i = 0; i < _inputNodes.Length; ++i)
            {
                var valueNode = _manager.GetNodeById(_inputNodes[i]) as ValueAnimatedNode;
                if (valueNode == null)
                {
                    throw new InvalidOperationException(
                              "Illegal node ID set as an input for Animated.divide node.");
                }

                var value = valueNode.Value;
                if (i == 0)
                {
                    RawValue = value;
                    continue;
                }

                if (value == 0)
                {
                    throw new DivideByZeroException(
                              "Detected a division by zero in Animated.divide node.");
                }

                RawValue /= value;
            }
        }
        private double GetInputNodeValue()
        {
            var valueAnimatedNode = _manager.GetNodeById(_inputNodeTag) as ValueAnimatedNode;
            if (valueAnimatedNode == null) {
                throw new InvalidOperationException(
                    "Illegal node ID set as an input for Animated.DiffClamp node.");
            }

            return valueAnimatedNode.Value;
        }
Esempio n. 5
0
        public override void Update()
        {
            var animatedNode = _manager.GetNodeById(_inputNode);
            var valueNode    = animatedNode as ValueAnimatedNode;

            if (valueNode == null)
            {
                throw new InvalidOperationException(
                          "Illegal node ID set as an input for Animated.modulus node.");
            }

            RawValue = valueNode.Value % _modulus;
        }
        public override void Update()
        {
            RawValue = 1;
            foreach (var tag in _inputNodes)
            {
                var valueNode = _manager.GetNodeById(tag) as ValueAnimatedNode;
                if (valueNode == null)
                {
                    throw new InvalidOperationException(
                              "Illegal node ID set as an input for Animated.Add node.");
                }

                RawValue *= valueNode.Value;
            }
        }
Esempio n. 7
0
        public override void Update()
        {
            Value = 1;
            foreach (var tag in _inputNodes)
            {
                var valueNode = _manager.GetNodeById(tag) as ValueAnimatedNode;
                if (valueNode == null)
                {
                    throw new InvalidOperationException(
                              "Illegal node ID set as an input for Animated.Add node.");
                }

                Value *= valueNode.Value;

                //Log.Error(ReactConstants.Tag, "InterpolationAnimatedNode -> value = " + Value);
            }
        }
        public void UpdateView(UIImplementation uiImplementation)
        {
            if (ConnectedViewTag == -1)
            {
                throw new InvalidOperationException("Node has not been attached to a view.");
            }

            var propsMap = new JObject();

            foreach (var entry in _propMapping)
            {
                var node      = _manager.GetNodeById(entry.Value);
                var styleNode = node as StyleAnimatedNode;
                var valueNode = default(ValueAnimatedNode);
                if (styleNode != null)
                {
                    styleNode.CollectViewUpdates(propsMap);
                }
                else if ((valueNode = node as ValueAnimatedNode) != null)
                {
                    propsMap.Add(entry.Key, valueNode.Value);
                }
                else
                {
                    throw new InvalidOperationException(
                              Invariant($"Unsupported type of node used in property node '{node.GetType()}'."));
                }
            }

            // TODO: Reuse propsMap and stylesDiffMap objects - note that in
            // subsequent animation steps for a given node most of the time
            // will be creating the same set of props (just with different
            // values). We can take advantage on that and optimize the way we
            // allocate property maps (we also know that updating view props
            // doesn't retain a reference to the styles object).
            var updated = uiImplementation.SynchronouslyUpdateViewOnDispatcherThread(
                ConnectedViewTag,
                new ReactStylesDiffMap(propsMap));

            if (!updated)
            {
                Tracer.Error(ReactConstants.Tag, "Native animation workaround, frame lost as result of race condition.", null);
            }
        }
 public void CollectViewUpdates(JObject propsMap)
 {
     foreach (var entry in _propMapping)
     {
         var node = _manager.GetNodeById(entry.Value);
         if (node is TransformAnimatedNode transformNode)
         {
             transformNode.CollectViewUpdates(propsMap);
         }
         else if (node is ValueAnimatedNode valueNode)
         {
             propsMap[entry.Key] = valueNode.Value;
         }
         else
         {
             throw new InvalidOperationException($"Unsupported type of node used in property node: '{node.GetType()}'");
         }
     }
 }
        public override void Update()
        {
            for (int i = 0; i < _inputNodes.Length; ++i)
            {
                var valueNode = _manager.GetNodeById(_inputNodes[i]) as ValueAnimatedNode;
                if (valueNode == null)
                {
                    throw new InvalidOperationException(
                              "Illegal node ID set as an input for Animated.subtract node.");
                }

                var value = valueNode.Value;
                if (i == 0)
                {
                    RawValue = value;
                    continue;
                }

                RawValue -= value;
            }
        }
 public void CollectViewUpdates(JObject propsMap)
 {
     foreach (var entry in _propMapping)
     {
         var node          = _manager.GetNodeById(entry.Value);
         var transformNode = node as TransformAnimatedNode;
         var valueNode     = default(ValueAnimatedNode);
         if (transformNode != null)
         {
             transformNode.CollectViewUpdates(propsMap);
         }
         else if ((valueNode = node as ValueAnimatedNode) != null)
         {
             propsMap.Add(entry.Key, valueNode.Value);
         }
         else
         {
             throw new InvalidOperationException(
                       Invariant($"Unsupported type of node used in property node: '{node.GetType()}'"));
         }
     }
 }